Main Content

基于 C/C++ 代码创建模块库

使用 Simulink® 代码导入器基于 C/C++ 代码创建 Simulink 库

使用 Simulink 代码导入器工具从您的自定义 C/C++ 代码库构建 Simulink 库。Simulink 代码导入器在分析函数的自定义代码及其依存关系(包括函数使用的全局变量和类型)后,将自定义代码作为可调用函数放入由 C Caller 模块构成的 Simulink 库中。

Simulink 代码导入器在分析自定义代码的类及其依存关系后,会将自定义 C++ 类导入 C Function 模块库中。 (自 R2024a 起)

要使用 Simulink 代码导入器,请转至 Simulink 工具条中的建模选项卡。从设计中,选择代码导入器。然后,按照一系列屏幕上的指示,完成从自定义代码创建 Simulink 库的过程。

您也可以创建一个 Simulink.CodeImporter 类对象,并使用命令行界面运行 Simulink代码导入器工具。

如果您有 Simulink Test™ 许可证,您可以使用 Simulink 代码导入器对您的自定义 C/C++ 代码执行单元测试或集成测试。请参阅导入和测试自定义 C/C++ 代码 (Simulink Test)

Simulink.CodeImporterImport custom C/C++ code into Simulink (自 R2021a 起)
Simulink.CodeImporter.CustomCodeSpecify custom code settings for Simulink.CodeImporter and sltest.CodeImporter classes (自 R2021a 起)
Simulink.CodeImporter.OptionsSpecify additional import options for Simulink.CodeImporter and sltest.CodeImporter classes (自 R2021a 起)
Simulink.CodeImporter.ParseInfoInformation about parsed custom code (自 R2021a 起)
Simulink.CodeImporter.FunctionAccess and configure detailed information about parsed custom code functions (自 R2021a 起)
Simulink.CodeImporter.SimulinkPortSpecificationConfigure port specification for imported custom code (自 R2021a 起)

模块

C CallerIntegrate C code in Simulink
C FunctionIntegrate and call external C/C++ code from a Simulink model (自 R2020a 起)

主题