自定义工具链注册
注册和使用第三方软件编译工具链以创建可执行文件和库
工具链是指将源代码转换为二进制工件(如静态或动态库或可执行文件)的一组编译工具(编译应用程序、编译器、链接器、存档器)。例如,在 Linux 中,您可以用 gmake
为 C 文件调用工具链,并在联编文件中设置工具链信息。对于 C/C++ 代码生成,工具链是在一个可通过工具链定义文件(M 文件)来修改和加载的 MATLAB® 对象中形式化定义的。当您对编译过程执行密集自定义时,请编写并使用您自己的工具链定义文件。
MATLAB Coder™ 工具链基础架构基于名为 coder.make.ToolchainInfo
的类。在实例化对象中,对象属性可存储形式化工具链信息,例如编译工具的路径,调用编译工具的命令的语法,以及附加到命令的标志。特定的 coder.make.ToolchainInfo
方法允许访问和修改工具链对象属性。代码生成器使用完成的对象定义来为工具链创建和调用联编文件。
在代码生成基础架构中,先是通过工具链定义文件创建工具链对象,保存对象,再注册该对象以用于代码生成。然后,将对象名称赋给代码生成配置对象的 Toolchain
属性。有关完整的演示,请参阅精选示例。
类
coder.make.BuildConfiguration | Represent build configuration |
coder.make.BuildItem | Represent build item |
coder.make.BuildTool | Represent build tool |
coder.make.ToolchainInfo | Represent custom toolchain |
主题
自定义工具链注册基础知识
- Custom Toolchain Registration
Register third-party software build tools for creating executables and libraries. - About coder.make.ToolchainInfo
coder.make.ToolchainInfo
represents a custom toolchain. - Toolchain Definition File with Commentary
Create a toolchain definition file.
典型工作流
- 创建和编辑工具链定义文件
为一个新的自定义工具链创建和编辑工具链定义文件。 - Create and Validate ToolchainInfo Object
Create and validate a ToolchainInfo object from the toolchain definition file. - Register the Custom Toolchain
Register custom toolchain before you use it. - Use the Custom Toolchain
Build an executable or library with the custom toolchain.
故障排除
- Troubleshooting Custom Toolchain Validation
Troubleshoot validation errors. - Prevent Circular Data Dependencies with One-Pass or Single-Pass Linkers
UseStartLibraryGroup
andEndLibraryGroup
linker directives.