编译配置
编译设置的配置,例如输出文件的名称、位置、类型、语言
要控制和配置生成二进制代码的编译过程,需要使用许多参数和设置。这些设置用来控制一些属性,如输出的编译类型(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. - 路径和文件基础架构设置
指定自定义代码的位置。 - Build Process Support for File and Folder Names
Troubleshoot build process errors that occur when file system issues prevent file processing. - Share Build Configuration Settings
Export project settings to a code generation configuration object or import the settings into a project. - Specify Code Configuration Parameters Interactively
Configure the code generation process by using the Code Generation Settings dialog box. - 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.
特定编译选项
- 在生成代码中保留变量名称
通过在生成代码中保留变量名称来提高生成的 C/C++ 代码的可读性。 - Understand and Control Partitioning of the Generated Code
Understand how file partitioning method and inlining settings interact to control the partitioning of the generated code. - 更改用于代码生成的语言标准
代码生成器使用您在编译设置中指定的语言标准。 - Register New Hardware Devices
Extend the range of supported hardware by registering new devices. - 配置 CMake 编译过程
为编译生成的代码指定 CMake 工具链定义。 - 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.
故障排除
- 编译器和链接器错误
解决在编译过程中出现错误的常见原因。