MATLAB: Generate Code From a Model That Uses an External Linux Library

.soarmcoderdllembeddedEmbedded Coderlibrary

I have a Simulink model which currently calls a Windows library (.dll) using S-functions. I would now like to generate code from my model for a Linux target (such as ARM). How do I link against the Linux version of the library for use on the target?

Best Answer

To use the Windows library for simulation and Linux library for code generation, you must first install the Linux library on your target. Then, in your Simulink model, navigate to Model Configuration Parameters > Code Generation > Custom Code. Under "Additional build information", specify the path and name of the library in "Libraries". Specify any necessary header files and include directories as needed in the other fields. When the model deploys to the target, it will then link against this library.
More information about including external code during code generation can be found here:
Please note that the library information specified in "Custom Code" is only used for code generation, and not for simulation. Simulation information can be specified in the "Simulation Target" section of Model Configuration Parameters.
Finally, note that you must have TLC files for your S-functions if you want to inline them in the generated code. More information about this can be found at the link below.