Main Content

Build Configuration

Configuration of build settings such as output file name, location, type, language

To control and configure the build process for generating binary code, there are many parameters and settings. These settings control attributes such as the output build type (MEX, lib, dll, or exe) and C versus C++ language. Other build settings enable you to customize the build output according to specific needs, such as readability, performance, and external code integration. You can modify the build options in the code generation configuration object from the app or at the command line. You can create the configuration object by using coder.config. Open the object in the editing app using open. To specify additional build files and flags from inside your function code, use coder.updateBuildInfo.

Functions

expand all

coder.configCreate code generation configuration objects
coder.updateBuildInfoUpdate RTW.BuildInfo build information object
target.addAdd target object to internal database
target.clearClear all target objects from internal database (Since 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 (Since 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 (Since R2024a)
addSourceFilesAdd source files to build information
addSourcePathsAdd source paths to build information
addUndefinesAdd undefine preprocessor directives to build information (Since R2024a)
removeIncludePathsRemove include paths from build information (Since R2023b)
removeSourceFilesRemove source files from build information object (Since R2021b)
removeUndefinesRemove undefine preprocessor macros from build information (Since 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 (Since R2024a)
getSourceFilesGet source files from build information
getSourcePathsGet source paths from build information
getUndefinesFrom build information, get preprocessor macros to undefine (Since 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

Code Configuration Settings

expand all

Build typeOutput to build from generated C/C++ code
LanguageLanguage to use in generated code
Language standardLanguage standard to use for the generated code
Custom output fileName of code generation output file
Generate code onlyGeneration of only source code
Verification modeCode verification mode
Build folderFolder type for files generated during build process
Build folder pathFolder path for files generated during build process
Working folderCurrent working folder type for build process
Working folder pathCurrent working folder path for build process
Enable responsiveness to CTRL+C and graphics refreshingResponsiveness checks
Keep extrinsic callsExtrinsic function call support
Check memory integrityMemory integrity checking
Saturate on integer overflowInteger overflow support
Support only purely-integer numbersDetection of floating-point code
Support nonfinite numbersSupport for nonfinite values
Loop unrolling thresholdThreshold on the number of iterations that determines whether to automatically unroll a for-loop and a parfor-loop
Preserve input data for entry-point functionsWhether to protect entry-point input data from modification
Enable OpenMP library if possibleParallelization of parfor-loops
Enable automatic parallelizationAutomatic parallelization of for loops
Maximum number of CPU threadsMaximum number of CPU threads to run parallel for-loops
Leverage target hardware instruction set extensionsSIMD instruction set for target hardware
FMAWhether to use SIMD instructions for fused multiply add operations
Inline strategy for user written MATLAB functionsControl inlining between user-written functions
Inline strategy for MathWorks written MATLAB functionsControl inlining between MathWorks functions
Inline strategy for calls between MathWorks functions and user functionsControl inlining between user-written functions and MathWorks functions
Optimize reductionsGenerate SIMD code for reduction operations | Parallelize for-loops performing reduction operations
Hardware SIMD accelerationLevel of SIMD intrinsics
Global data synchronization modeGlobal data synchronization mode
Enable variable-sizingVariable-size array support
Enable dynamic memory allocationEnable dynamic memory allocation for variable-size arrays
Dynamic memory allocation thresholdSize threshold for dynamic memory allocation of variable-size arrays
Enable dynamic memory allocation for fixed-sized arraysDynamic memory allocation for fixed-size arrays
Dynamic memory allocation interfaceDynamically allocated array at generated function interface
Array layoutRow-major array layout
Preserve array dimensionsN-dimensional indexing
Stack usage maxMaximum stack usage per application
Generate re-entrant codeMulti-instance, reentrant code
Preserve unused fields and propertiesPreserve unused class properties or structure fields in the generated C/C++ code
Generated file partitioning methodFile partitioning mode
Large constant generationWhether to write large deep learning constants to binary data files
Large constant thresholdThreshold above which the code generator writes DNN constants to binary data files
Include commentsComments in generated code
Comment styleComment style in the generated code
MATLAB source code as commentsInclusion of MATLAB source code as comments in generated code
MATLAB source code comment line numbersInclude line numbers of MATLAB source code as comments in the generated code
MATLAB function help text MATLAB function help text in function banner
Requirement summaries as commentsInclude requirements links as comments
Convert if-elseif-else patterns to switch-case statementsConversion of if-elseif-else patterns to switch-case statements
Preserve extern keyword in function declarationsPreservation of the extern keyword in function declarations
Use signed shift left for fixed-point operations and multiplication by powers of 2Replacement of multiplications by powers of two with signed left bitwise shifts
Allow right shifts on signed integersSigned right bitwise shifts in generated code
ParenthesesParenthesization level in the generated code
Maximum identifier lengthMaximum number of characters in generated identifiers
Header guard styleStyle of preprocessor directive in generated code
Indent styleStyle for placement of braces in the generated code
Indent sizeNumber of characters per indentation level
Column limitMaximum number of columns before a line break in the generated code
Data type replacementData type replacement in generated code
Enable custom data type replacementCustom names for data types in generated code
Import custom types from external header filesWhether to import type definition from external header files
Header filesExternal header files that contain custom type definitions
Global variablesCustom identifier format for global variable identifiers
Global typesCustom identifier format for global type identifiers
Field name of global typesCustom identifier format for field names in global type identifiers
Local functionsCustom identifier format for local function identifiers
Local temporary variablesCustom identifier format for local temporary variable identifiers
Constant macrosCustom identifier format for constant macro identifiers
EMX array typesCustom identifier format for EMX array types
EMX array utility functionsCustom identifier format for EMX array utility functions
Generated source and header file name formatFile name customization macro
Code generation template fileCode generation template for file and function banners
Select code format tool to useFormatting tool for generated code
Control use of clang format configurationControl generation of clang-format file
Enable C/C++ compiler debug modeC compiler debugging mode
Generate run-time error checksRun-time error detection and reporting in generated code
Show verbose compiler outputCode generation progress display
Always create a reportCode generation report
Report differences from MATLABPotential differences reporting
Highlight potential data type issuesHighlighting of potential data type issues in the code generation report
Highlight potential row-major issuesPotential row-major layout issues
Highlight potential issues resulting from implicit expansionHighlight potential implicit expansion issues
Highlight potential issues in use of coder.loop functionsHighlight potential loop control issues
Generate static code metrics reportStatic code metrics report
Generate code replacements reportCode replacement report
Automatically launch a report if one is generatedAutomatic open of code generation report
Export report information to variableName of variable containing code generation report information
Enable source-level debugging for SIL or PILDebugging of generated code during a SIL or PIL execution
Check constant inputsConstant input checking mode for a SIL or PIL execution
Synchronize global dataGlobal data synchronization mode for a SIL or PIL execution
Enable entry point execution profilingExecution time profiling during a SIL or PIL execution
Enable function execution profilingExecution time profiling of functions called within entry-point functions during a SIL or PIL execution
Specify profiling save optionsCollection and storage of execution-time measurements
Enable entry point stack profilingStack usage profiling during a SIL or PIL execution
Enable C/C++ code coverageAnalysis of C/C++ code coverage
Enable execution profilingInstrumentation for profiling
Code replacement libraryCode replacement library for generated code
Use built-in FFTW libraryGenerate code that uses the FFTW library shipped with MATLAB
Custom FFT library callbackCallback class for FFTW library calls
Custom BLAS library callbackBLAS callback class
Custom LAPACK library callbackLAPACK callback class
Use precompiled librariesWhether to use precompiled libraries in generated code
Source fileCode to appear near the top of generated .c or .cpp files
Header fileCustom code that appears at top of generated C/C++ header files
Initialize functionCustom code to include in the generated initialize function
Terminate functionCode that appears in the generated terminate function
Additional include directoriesInclude folders to add to include path for compiling generated code
Additional source filesSource files to compile and link with the generated code
Additional librariesStatic library files to link with the generated code
Post-code-generation commandCommand to customize build processing
Reserved namesNames that code generator must not use for functions or variables
Hardware boardName of hardware board
Production Device Details: Device vendorManufacturer of production hardware
Production Device Details: Device typeType of production hardware
Production Device Details: charLength in bits of the C char data type
Production Device Details: shortLength in bits of the C short data type
Production Device Details: intLength in bits of the C int data type
Production Device Details: longLength in bits of the C long data type
Production Device Details: long longLength in bits of the C long long data type
Production Device Details: floatLength in bits of the C floating-point data type
Production Device Details: doubleLength in bits of the C double data type
Production Device Details: machine wordMicroprocessor native word size
Production Device Details: pointerLength in bits of pointer data
Production Device Details: size_tLength in bits of size_t data
Production Device Details: ptrdiff_tLength in bits of ptrdiff_t data
Production Device Details: Byte orderingSignificance of the first byte of a data word
Production Device Details: Shift right on a signed integer as an arithmetic shiftImplementation of signed integer right shift as arithmetic right shift
Production Device Details: Enable long longLong long data type support
Production Device Details: Largest atomic integer sizeLargest atomic integer size for production hardware
Production Device Details: Largest atomic floating-point sizeLargest atomic floating-point size for production hardware
Production Device Details: Signed integer division rounds toRounding for division of two signed integers
Target Device Details: Device vendorManufacturer of test hardware
Target Device Details: Device typeType of test hardware
Test Device Details: charLength in bits of the C char data type
Test Device Details: shortLength in bits of the C short data type
Test Device Details: intLength in bits of the C int data type
Test Device Details: longLength in bits of the C long data type
Test Device Details: long longLength in bits of the C long long data type
Test Device Details: floatLength in bits of the C floating-point data type
Test Device Details: doubleLength in bits of the C double data type
Test Device Details: machine wordMicroprocessor native word size
Test Device Details: pointerLength in bits of pointer data
Test Device Details: size_tLength in bits of size_t data
Test Device Details: ptrdiff_tLength in bits of ptrdiff_t data
Test Device Details: Byte orderingSignificance of the first byte of a data word
Test Device Details: Shift right on a signed integer as an arithmetic shiftImplementation of signed integer right shift as arithmetic right shift
Test Device Details: Enable long longLong long data type support
Test Device Details: Largest atomic integer sizeLargest atomic integer size for test hardware
Test Device Details: Largest atomic floating-point sizeLargest atomic floating-point size for test hardware
Test Device Details: Signed integer division rounds toRounding for division of two signed integers
ToolchainToolchain to use for building a C/C++ library or executable program
Custom Toolchain OptionsCustom settings for tools in selected toolchain
Build configuration Compiler optimization or debug settings for toolchain
Test Hardware is the same as production hardwareEquivalence of production and target hardware characteristics
C++ namespaceNamespace name for generated C++ code
Interface styleInterface style for generated C++ code
C++ interface class nameInterface class name for generated C++ code
Generate C++ namespaces from MATLAB namespacesGenerate C++ namespaces for MATLAB namespaces
Namespace for MathWorks codePlace C++ code generated for MathWorks code in a separate namespace
Generate C++ classes from MATLAB classesGenerate C++ classes for MATLAB classes
Generate C++ enum class from MATLAB enumerationWhether to generate C++ enumeration classes for MATLAB enumerations
Casting modeData type casting level
Constant folding timeoutMaximum number of instructions to be executed by the constant folder
Compile-time recursion limitMaximum number of function specializations for compile-time recursion
Automatically run the initialize functionAutomatically run the initialize function
Initialize function requiredInitialize function generation
Terminate function requiredTerminate function generation
Generate justification comments for known MISRA violationsAdd annotations to suppress known MISRA/AUTOSAR violations
Generate example mainExample C/C++ main file generation
Preserve variable namesVariable names to preserve in the generated code
Echo expressions without terminating semicolonsExpression echoing
Generate makefileMakefile generation
Automatically introduce extrinsic callsAutomatic extrinsic function calls
Simplify array indexingStrength reduction optimization
Use memcpy for vector assignment Whether to enable memcpy optimization
Memcpy threshold (bytes)Minimum size for memcpy or memset optimization
Use memset to initialize floats and doubles to 0.0Assignment of float and double zero with memset
Constant inputsConstant input checking mode
Use JIT compilation for build type of MEXJust-in-time (JIT) compilation mode
Generate nonfinite support files if usedGenerate support files for nonfinite data only if nonfinite data is used
Pass structures by reference to entry-point functionsPass structures by reference
Always generate a default case for switchDefault case for all switch statements
Enable code traceabilityTraceability in code generation report
Use Embedded Coder featuresWhether to use Embedded Coder features
Enable implicit expansionImplicit expansion capabilities in generated code
Enable automatic parallelization reportingReporting for automatic parallelization of for loops
Enable run-time recursionRun-time recursion support
Cache dynamic array dataDynamic array optimization
SIL/PIL VerbosityDisplay communication I/O information during SIL or PIL execution
SIL/PIL profiling metricsPMU metric

Objects

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.BuildInfoProvide information for compiling and linking generated code

Classes

coder.ExternalDependencyInterface to external code
target.AliasCreate alternative identifier for target object
target.CMakeSpecify CMake installation for building generated code (Since R2022b)
target.CMakeBuilder Configure how CMake builds generated code (Since R2022b)
target.CMakeBuildTypeDescribe CMake build type or build configuration (Since R2022b)
target.CMakeCacheEntryConfigure a CMake cache entry (Since R2022b)
target.EnvironmentConfigurationConfigure system environment for toolchain (Since R2022b)
target.HardwareComponentSupportDescribe support for a hardware component (Since R2022b)
target.LanguageImplementationProvide C and C++ compiler implementation details
target.ObjectBase class for target types
target.ProcessorProvide target processor information
target.ToolchainCapture high-level information about toolchain (Since R2022b)

Namespaces

targetManage target hardware and build tool information

Topics

Build Configuration Basics

Specific Build Options

Troubleshooting

Featured Examples