Getting "Undefined reference to" errors when building S-Function using S-Function Builder block

조회 수: 16 (최근 30일)
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
Piyush Kumar
Piyush Kumar 2024년 5월 14일
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.
Saiesh Singh
Saiesh Singh 2024년 5월 15일
Hi Piyush,
It would seem I missed adding the ENTRY for the source files. With that the "undefined reference to" errors are gone but now I am getting some new errors:
C:\Users\User\AppData\Local\Temp\ccgb5CZf.s: Assembler messages: C:\Users\User\AppData\Local\Temp\ccgb5CZf.s:16: Error: no such instruction: `mrs %eax,primask' C:\Users\User\AppData\Local\Temp\ccgb5CZf.s:43: Error: no such instruction: `mrs %ecx,primask' C:\Users\User\AppData\Local\Temp\ccgb5CZf.s:62: Error: no such instruction: `cpsid i' C:\Users\User\AppData\Local\Temp\ccgb5CZf.s:95: Error: no such instruction: `cpsie i' C:\Users\User\AppData\Local\Temp\ccgb5CZf.s:124: Error: no such instruction: `mrs %ecx,primask' C:\Users\User\AppData\Local\Temp\ccgb5CZf.s:143: Error: no such instruction: `cpsid i' C:\Users\User\AppData\Local\Temp\ccgb5CZf.s:176: Error: no such instruction: `cpsie i' C:\Users\User\AppData\Local\Temp\ccgb5CZf.s:205: Error: no such instruction: `mrs %ecx,primask' C:\Users\User\AppData\Local\Temp\ccgb5CZf.s:224: Error: no such instruction: `cpsid i' C:\Users\User\AppData\Local\Temp\ccgb5CZf.s:257: Error: no such instruction: `cpsie i' C:\Users\User\AppData\Local\Temp\ccgb5CZf.s:286: Error: no such instruction: `mrs %ecx,primask' C:\Users\User\AppData\Local\Temp\ccgb5CZf.s:305: Error: no such instruction: `cpsid i' C:\Users\User\AppData\Local\Temp\ccgb5CZf.s:338: Error: no such instruction: `cpsie i'
Component:S-function Builder | Category:Build error
What could be the issue?

댓글을 달려면 로그인하십시오.

답변 (1개)

Jaimin
Jaimin 2024년 12월 26일
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:
  1. 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.
  2. 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.
I hope this will be helpful.

카테고리

Help CenterFile Exchange에서 Simulink Coder에 대해 자세히 알아보기

제품


릴리스

R2022a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by