Create Block Library from C/C++ Code
Use the Simulink Code Importer tool to build a Simulink library from your custom C/C++ code library. The Simulink Code Importer brings custom code into a Simulink library of C Caller blocks as callable functions, after analyzing the custom code for functions and their dependencies, including global variables and types used by the functions.
The Simulink Code Importer imports custom C++ class into a library of C Function blocks after analyzing the custom code for classes and their dependencies. (since R2024a)
To use the Simulink Code Importer, go to the
Modeling tab on the Simulink toolstrip. From Design,
choose Code Importer
. A series of
screens then leads you through the process of creating a
Simulink library from your custom code.
Alternatively, you can create an object of the
Simulink.CodeImporter
class and run the
Simulink Code Importer tool using a command-line
interface.
If you have a Simulink Test™ license, you can use the Simulink Code Importer to perform unit testing or integration testing on your custom C/C++ code. See Importing and Testing Custom C/C++ Code (Simulink Test).
Classes
Simulink.CodeImporter | Import custom C/C++ code into Simulink (Since R2021a) |
Simulink.CodeImporter.CustomCode | Specify custom code settings for Simulink.CodeImporter and
sltest.CodeImporter classes (Since R2021a) |
Simulink.CodeImporter.Options | Specify additional import options for Simulink.CodeImporter and
sltest.CodeImporter classes (Since R2021a) |
Simulink.CodeImporter.ParseInfo | Information about parsed custom code (Since R2021a) |
Simulink.CodeImporter.Function | Access and configure detailed information about parsed custom code functions (Since R2021a) |
Simulink.CodeImporter.SimulinkPortSpecification | Configure port specification for imported custom code (Since R2021a) |
Blocks
C Caller | Integrate C code in Simulink |
C Function | Integrate and call external C/C++ code from a Simulink model (Since R2020a) |
Topics
- Import Custom Code Using the Simulink Code Importer Wizard
Use the Simulink Code Importer to create a library of C Caller blocks from your custom C/C++ code.
- Import Custom C++ Class Using the Simulink Code Importer Wizard
Use Simulink Code Importer wizard to import custom C++ class.