- Open your Simulink model. Drag and drop the S-Function Builder block from the Simulink Library Browser into the model.
- Double-click on the S-Function Builder block to open the block parameters. In the "Source files" field, specify the path to the C++ code files that contain the class definitions and inheritance relationships.
- In the "Additional Include Directories" field and "Additional Linker Directories" field, specify the paths to the directories containing the libraries required by your code. Configure any other parameters as needed for your specific code.
- Connect the S-Function Builder block to the rest of your Simulink model as required.
Can I interface C++ code with simulink using S-function builder?
2 views (last 30 days)
Show older comments
I am exploring the possibility of replacing our existing C++ code with simulink. This C++ code involves inheritance, ploymorphism, classes, nested namespace and C++ dependent libraries. Is it possible to define and access classes and related inheritance using S-function builder? How would I import the C++ libraries? I am currently using R2018b.
0 Comments
Answers (1)
Maneet Kaur Bagga
on 27 Sep 2023
Hi Aditya,
As per my understanding, to import C++ libraries into Simulink, please refer to the "Additional Include Directories" and "Additional Linker Directories" options in the S-Function Builder block. These options allow to specify the paths to the header files and libraries required by the C++ code. Please refer to the below steps:
Please refer to the following documentation for better understanding of the above steps:
Hope this helps!
Regards,
Maneet Bagga
0 Comments
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!