Main Content

编译配置

编译设置的配置,例如输出文件的名称、位置、类型、语言

要控制和配置生成二进制代码的编译过程,需要使用许多参数和设置。这些设置用来控制一些属性,如输出的编译类型(MEX、lib、dll 或 exe),以及输出的语言是 C 还是 C++ 等等。其他编译设置允许您根据特定要求自定义编译输出,例如可读性、性能和外部代码集成。您可以从 App 或从命令行修改代码生成配置对象中的编译选项。使用 coder.config 创建配置对象。使用 open 在编辑 App 中打开对象。要从函数代码内指定其他编译文件和标志,请使用 coder.updateBuildInfo

函数

全部展开

coder.config创建 MATLAB Coder 代码生成配置对象
coder.updateBuildInfoUpdate RTW.BuildInfo build information object
target.addAdd target object to internal database
target.clearClear all target objects from internal database (自 R2023a 起)
target.createCreate target object
target.exportExport target object data
target.getRetrieve target objects from internal database
target.removeRemove target object from internal database
target.updateUpdate target objects in internal database (自 R2023a 起)
target.upgradeUpgrade existing definitions of hardware devices
addCompileFlagsAdd compiler options to build information
addDefinesAdd preprocessor macro definitions to build information
addIncludeFilesAdd include files to build information
addIncludePathsAdd include paths to build information
addLinkFlagsAdd link options to build information
addLinkObjectsAdd link objects to build information
addNonBuildFilesAdd nonbuild-related files to build information
addPreincludeFilesAdd preinclude files to build information (自 R2024a 起)
addSourceFilesAdd source files to build information
addSourcePathsAdd source paths to build information
addUndefinesAdd undefine preprocessor directives to build information (自 R2024a 起)
removeIncludePathsRemove include paths from build information (自 R2023b 起)
removeSourceFilesRemove source files from build information object (自 R2021b 起)
removeUndefinesRemove undefine preprocessor macros from build information (自 R2024a 起)
findBuildArgFind a specific build argument in build information
findIncludeFilesFind and add include (header) files to build information
getBuildArgsGet build arguments from build information
getCompileFlagsGet compiler options from build information
getDefinesGet preprocessor macro definitions from build information
getFullFileListGet list of files from build information
getIncludeFilesGet include files from build information
getIncludePathsGet include paths from build information
getLinkFlagsGet link options from build information
getNonBuildFilesGet nonbuild-related files from build information
getPreincludeFilesGet preinclude files from build information (自 R2024a 起)
getSourceFilesGet source files from build information
getSourcePathsGet source paths from build information
getUndefinesFrom build information, get preprocessor macros to undefine (自 R2024a 起)
setTargetProvidesMainDisable inclusion of code generator provided (generated or static) main.c source file during build
updateFilePathsAndExtensionsUpdate files in build information with missing paths and file extensions
updateFileSeparatorUpdate file separator character for file lists in build information

对象

coder.MexCodeConfigConfiguration parameters for MEX function generation from MATLAB code
coder.CodeConfigConfiguration parameters for C/C++ code generation from MATLAB code
coder.EmbeddedCodeConfigConfiguration parameters for C/C++ code generation from MATLAB code with Embedded Coder
coder.HardwareImplementationHardware-specific configuration parameters for C/C++ code generation from MATLAB code
coder.hardwareCreate hardware board configuration object for C/C++ code generation from MATLAB code
coder.ReplacementTypesConfiguration parameter to specify custom names for MATLAB built-in data types in C/C++ code generation
RTW.BuildInfo提供用于编译和链接生成的代码的信息

coder.ExternalDependencyInterface to external code
target.AliasCreate alternative identifier for target object
target.CMakeSpecify CMake installation for building generated code (自 R2022b 起)
target.CMakeBuilder Configure how CMake builds generated code (自 R2022b 起)
target.CMakeBuildTypeDescribe CMake build type or build configuration (自 R2022b 起)
target.CMakeCacheEntryConfigure a CMake cache entry (自 R2022b 起)
target.EnvironmentConfigurationConfigure system environment for toolchain (自 R2022b 起)
target.HardwareComponentSupportDescribe support for a hardware component (自 R2022b 起)
target.LanguageImplementation提供 C 和 C++ 编译器实现详细信息
target.Object用于目标类型的基类
target.ProcessorProvide target processor information
target.ToolchainCapture high-level information about toolchain (自 R2022b 起)

命名空间

target管理目标硬件和编译工具信息

主题

编译配置基础知识

特定编译选项

故障排除

精选示例