Getting "Undefined reference to" errors when building S-Function using S-Function Builder block
17 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
I am creating a S-Function in simulink with the S-Function Builder block. I was initially facing "file not found" errors for some of the headers I am using in the code which got resolved after I put the entire path to the headers and source files in the libraries tab of the builder. However, I am now getting "undefined reference to" errors for all the functions that use the headers I included.
C:\Users\User\AppData\Local\Temp\mex_90014370683397_13052\NVMRead_wrapper.obj:NVMRead_wrapper.c:(.text+0x76): undefined reference to `Fee_MainFunction' C:\Users\User\AppData\Local\Temp\mex_90014370683397_13052\NVMRead_wrapper.obj:NVMRead_wrapper.c:(.text+0x7b): undefined reference to `MemAcc_MainFunction' C:\Users\User\AppData\Local\Temp\mex_90014370683397_13052\NVMRead_wrapper.obj:NVMRead_wrapper.c:(.text+0x80): undefined reference to `Fee_GetStatus' C:\Users\User\AppData\Local\Temp\mex_90014370683397_13052\NVMRead_wrapper.obj:NVMRead_wrapper.c:(.text+0xa5): undefined reference to `Fee_Read' C:\Users\User\AppData\Local\Temp\mex_90014370683397_13052\NVMRead_wrapper.obj:NVMRead_wrapper.c:(.text+0xb6): undefined reference to `Fee_MainFunction' C:\Users\User\AppData\Local\Temp\mex_90014370683397_13052\NVMRead_wrapper.obj:NVMRead_wrapper.c:(.text+0xbb): undefined reference to `MemAcc_MainFunction' C:\Users\User\AppData\Local\Temp\mex_90014370683397_13052\NVMRead_wrapper.obj:NVMRead_wrapper.c:(.text+0xc0): undefined reference to `Fee_GetStatus' C:\Users\User\AppData\Local\Temp\mex_90014370683397_13052\NVMRead_wrapper.obj:NVMRead_wrapper.c:(.text+0xe8): undefined reference to `Fee_Read' C:\Users\User\AppData\Local\Temp\mex_90014370683397_13052\NVMRead_wrapper.obj:NVMRead_wrapper.c:(.text+0xf6): undefined reference to `Fee_MainFunction' C:\Users\User\AppData\Local\Temp\mex_90014370683397_13052\NVMRead_wrapper.obj:NVMRead_wrapper.c:(.text+0xfb): undefined reference to `MemAcc_MainFunction' C:\Users\User\AppData\Local\Temp\mex_90014370683397_13052\NVMRead_wrapper.obj:NVMRead_wrapper.c:(.text+0x100): undefined reference to `Fee_GetStatus' C:\Users\User\AppData\Local\Temp\mex_90014370683397_13052\NVMRead_wrapper.obj:NVMRead_wrapper.c:(.text+0x128): undefined reference to `Fee_Read' C:\Users\User\AppData\Local\Temp\mex_90014370683397_13052\NVMRead_wrapper.obj:NVMRead_wrapper.c:(.text+0x136): undefined reference to `Fee_MainFunction' C:\Users\User\AppData\Local\Temp\mex_90014370683397_13052\NVMRead_wrapper.obj:NVMRead_wrapper.c:(.text+0x13b): undefined reference to `MemAcc_MainFunction' C:\Users\User\AppData\Local\Temp\mex_90014370683397_13052\NVMRead_wrapper.obj:NVMRead_wrapper.c:(.text+0x140): undefined reference to `Fee_GetStatus' C:\Users\User\AppData\Local\Temp\mex_90014370683397_13052\NVMRead_wrapper.obj:NVMRead_wrapper.c:(.text+0x168): undefined reference to `Fee_Read' C:\Users\User\AppData\Local\Temp\mex_90014370683397_13052\NVMRead_wrapper.obj:NVMRead_wrapper.c:(.text+0x176): undefined reference to `Fee_MainFunction' C:\Users\User\AppData\Local\Temp\mex_90014370683397_13052\NVMRead_wrapper.obj:NVMRead_wrapper.c:(.text+0x17b): undefined reference to `MemAcc_MainFunction' C:\Users\User\AppData\Local\Temp\mex_90014370683397_13052\NVMRead_wrapper.obj:NVMRead_wrapper.c:(.text+0x180): undefined reference to `Fee_GetStatus'
How do I resolve this? I am using Matlab 2022a
2 Kommentare
Piyush Kumar
am 14 Mai 2024
Hi Saiesh,
Refer to the "Use the Libraries Table to Specify External Code and Paths" section of the documentation - https://www.mathworks.com/help/releases/R2022a/simulink/sfg/s-function-builder-dialog-box.html and make sure that you are including the header and source files as mentioned in the documentation link. There are some examples available in the doc as well.
Antworten (1)
Jaimin
am 26 Dez. 2024
The errors you are encountering are related to assembly instructions that are not recognized by the assembler being used. These specific instructions (mrs, cpsid, and cpsie) are typically used in ARM assembly language, which suggests that the code you are trying to compile is intended for an ARM architecture, but it is being compiled with a toolchain that supports a different architecture, such as x86.
Here are some steps to address this issue within Simulink:
- Check Target Hardware Configuration: In the “Hardware Implementation” pane, ensure that the “Hardware board” is set to the correct target hardware. If you are targeting an ARM-based board, select the appropriate option from the list.
- Update S-Function Builder Settings: If you are using the "S-Function Builder, ensure that the settings within the builder are configured for the correct target. Double-click on the S-Function block to open the S-Function Builder. Check any custom code or assembly code to ensure it matches the target architecture
For more information kindly refer following MathWorks documentation.
Hardware Implementation Pane: https://www.mathworks.com/help/releases/R2022a/simulink/gui/hardware-implementation-pane.html
I hope this will be helpful.
0 Kommentare
Siehe auch
Kategorien
Mehr zu Implement C/C++ Code Using S-Function Builder finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!