MATLAB: How to include a link library for an S-function in a model that runs in Rapid Accelerator mode

dllliblinkerobjectsfunctionsimulink

I have a model that I would like to run in Rapid Accelerator mode. Within this model I have an S-function that is compiled with an external static library. Since Rapid Accelerator mode generates an executable from the model, I need a way to link this library with the S-function at simulation time. Is this possible?

Best Answer

There are two suggested ways to accomplish this:
[1] ADD THE OBJECT FILE TO THE SIMULATION CUSTOM CODE
You can specify additional libraries or objects to link a model with for simulation targets, following the steps below:
1. Open the Configuration Parameters for the model (Ctrl+E)
2. Navigate to "Simulation Target -> Custom Code" using the menu on the left
3. At the bottom of the Custom Code pane, note that there is a field named "Include list of additional:". Select "Libraries" in the menu on the left side of this field.
4. In the blank space on the right, please enter the name of the static library file that your S-function needs to be linked with.
Please see the following documentation for details:
<http://www.mathworks.com/help/simulink/gui/simulation-target-pane-custom-code.html>
[2] CREATE AN RTWMAKECFG FUNCTION FOR YOUR MODEL
This method is a bit more difficult than the first option, but it is the preferred method for this scenario. Essentially, you will be creating a function called rtwmakecfg.m in the same directory as your S-function component that specifies how your S-function should be built. You can add directories, libraries, and objects to the build with this file.
Please see the following documentation for instructions on how to accomplish this:
<http://www.mathworks.com/help/rtw/ug/s-functions-for-code-generation.html#bp67trh>