编译配置
编译设置的配置,例如输出文件的名称、位置、类型、语言
要控制和配置生成二进制代码的编译过程,需要使用许多参数和设置。这些设置用来控制一些属性,如输出的编译类型(MEX、lib、dll 或 exe),以及输出的语言是 C 还是 C++ 等等。其他编译设置允许您根据特定要求自定义编译输出,例如可读性、性能和外部代码集成。您可以从 App 或从命令行修改代码生成配置对象中的编译选项。使用 coder.config
创建配置对象。使用 open
在编辑 App 中打开对象。要从函数代码内指定其他编译文件和标志,请使用 coder.updateBuildInfo
。
函数
对象
coder.MexCodeConfig | Configuration parameters for MEX function generation from MATLAB code |
coder.CodeConfig | Configuration parameters for C/C++ code generation from MATLAB code |
coder.EmbeddedCodeConfig | Configuration parameters for C/C++ code generation from MATLAB code with Embedded Coder |
coder.HardwareImplementation | Hardware-specific configuration parameters for C/C++ code generation from MATLAB code |
coder.hardware | Create hardware board configuration object for C/C++ code generation from MATLAB code |
coder.ReplacementTypes | Configuration parameter to specify custom names for MATLAB built-in data types in C/C++ code generation |
RTW.BuildInfo | 提供用于编译和链接生成的代码的信息 |
类
coder.ExternalDependency | Interface to external code |
target.Alias | Create alternative identifier for target object |
target.CMake | Specify CMake installation for building generated code (自 R2022b 起) |
target.CMakeBuilder | Configure how CMake builds generated code (自 R2022b 起) |
target.CMakeBuildType | Describe CMake build type or build configuration (自 R2022b 起) |
target.CMakeCacheEntry | Configure a CMake cache entry (自 R2022b 起) |
target.EnvironmentConfiguration | Configure system environment for toolchain (自 R2022b 起) |
target.HardwareComponentSupport | Describe support for a hardware component (自 R2022b 起) |
target.LanguageImplementation | 提供 C 和 C++ 编译器实现详细信息 |
target.Object | 用于目标类型的基类 |
target.Processor | Provide target processor information |
target.Toolchain | Capture high-level information about toolchain (自 R2022b 起) |
命名空间
target | 管理目标硬件和编译工具信息 |
主题
编译配置基础知识
- 配置编译设置
在命令行或 MATLAB® Coder™ 中配置编译配置参数。 - Build Process Customization
Control aspects of the build process that occur after code generation but before compilation. - Paths and File Infrastructure Setup
Specify location of custom code. - Share Build Configuration Settings
Export project settings to a code generation configuration object or import the settings into a project. - Specify Configuration Parameters in Command-Line Workflow Interactively
Edit code generation configuration objects interactively. - C Compiler Considerations for Signed Integer Overflows
For accurate results from signed integer C operations, the C compiler must preserve wrap-on-overflow behavior. - Requirements for Signed Integer Representation
Compile generated code on a target that uses a two’s complement representation for signed integer values. - Build Process Support for File and Folder Names
Troubleshoot build process errors that occur when file system issues prevent file processing.
特定编译选项
- 在生成代码中保留变量名称
通过在生成代码中保留变量名称来提高生成的 C/C++ 代码的可读性。 - How MATLAB Coder Partitions Generated Code
Select file partitioning method. - Change Language Standard Used for Code Generation
The code generator uses the language standard that you specify in the build settings. - 指定在生成的代码中使用的数据类型
生成内置 C 类型或 MathWorks® 预定义类型。 - Register New Hardware Devices
Extend the range of supported hardware by registering new devices. - Configure CMake Build Process
Specify CMake toolchain definition for building generated code. - Create Custom CMake Toolchain Definition
CMake is a third-party, open-source tool for build process management. - Constant Input Checking in MEX Functions
Control whether a MEX function checks the value of a constant input argument.
故障排除
- 编译器和链接器错误
解决在编译过程中出现错误的常见原因。