S-Function not building in Simulink.

13 visualizzazioni (ultimi 30 giorni)
Rahul
Rahul il 9 Ott 2025
Risposto: Anjaneyulu Bairi il 15 Ott 2025
Hello,
I am using MATLAB 2024a. I am trying to build an S-Function block in simulink. So the block contains my code on how the functionality needs to operate. Now I am encountering a very weird issue with this. In the S-Funblock if at the input, I connect a constant block then I am able to build it, if I connect a data store read block or a 'goto from' block the S-Function does not build. The error that I recieve while building the s-function with a data store memory is C:/Akhila/TASKS/Library/sFuncLib/TEST/test_ert_rtw/test.c:37: undefined reference to `equate_Outputs_wrapper'.
Now the same s-function by having a constant block input builds. The wrapper file is already in place. I need a data store memory to be an input to the s-function as i want to manipulate its value after flashing it on pcb.
Then why am I not able to build the s-function? Can someone help me with the same?

Risposte (1)

Anjaneyulu Bairi
Anjaneyulu Bairi il 15 Ott 2025
Hi,
When building your S-Function block in Simulink, the error 'undefined reference to 'equate_Outputs_wrapper'` typically indicates that the code generator cannot find the implementation of your wrapper function during the build process. This issue often arises when the wrapper source file (such as `equate_Outputs_wrapper.c`) is not properly included in the build. With a Constant block as input, Simulink may optimize away certain code paths, allowing the build to succeed even if the wrapper file is missing. However, when using a Data Store Read or Goto/From block, the generated code requires the actual implementation of the wrapper function, leading to the linker error if it cannot be found.
To resolve this, ensure that your wrapper source file is included in the build process. If you are using the S-Function Builder, add the wrapper file under the "Additional source files" section. For hand-written S-Functions, make sure the wrapper file is in the same directory as your model or is specified in the model’s Code Generation > Custom Code settings. Also, verify that the Data Store Memory block is configured correctly for code generation (for example, with the Scope set to ExportedGlobal). After making these adjustments, clean and rebuild your model. These steps should resolve the linker error and allow you to use Data Store Memory or Goto/From blocks as inputs to your S-Function.
I hope this helps to solve the issue!

Community Treasure Hunt

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

Start Hunting!

Translated by