-c | Generate source code only. Do not invoke the make
command or build object code. For example, to produce a static C/C++ library
for function foo and generate source code only, use this
command:
This command replicates the default build type (Source
Code ) for the MATLAB
Coder app. |
-config:dll | Generate a dynamic C/C++ library using the default configuration
parameters. |
-config:exe | Generate a static C/C++ executable using the default configuration
parameters. |
-config:lib | Generate a static C/C++ library using the default configuration
parameters. |
-config:mex | Generate a MEX function using the default configuration
parameters. |
-config:single | Generate single-precision MATLAB code using the default configuration
parameters. Requires Fixed-Point Designer. |
-config config_object | Specify the configuration object that contains the code generation
parameters. config_object is one of the following
configuration objects:
coder.CodeConfig — Parameters for
standalone C/C++ library or executable generation if Embedded Coder® is not available.
% Configuration object for a dynamic linked library
cfg = coder.config('dll')
% Configuration object for an executable
cfg = coder.config('exe')
% Configuration object for a static standalone library
cfg = coder.config('lib')
coder.EmbeddedCodeConfig — Parameters for a
standalone C/C++ library or executable generation if Embedded Coder is available.
% Configuration object for a dynamic linked library
ec_cfg = coder.config('dll')
% Configuration object for an executable
ec_cfg = coder.config('exe')
% Configuration object for a static standalone library
ec_cfg = coder.config('lib')
coder.MexCodeConfig — Parameters for MEX
code generation.
mex_cfg = coder.config
% or
mex_cfg = coder.config('mex')
For more information, see Configure Code Generation and Build Settings. |
-d out_folder | Store generated files in the absolute or relative path specified by
out_folder . out_folder
must not contain:
Spaces, as spaces can lead to code generation failures in certain
operating system configurations. Non 7-bit ASCII characters, such as Japanese characters,
If the folder specified by
out_folder does not exist,
codegen creates it. If you do not specify
the folder location, codegen generates files in the
default folder:
target
can be:
mex for MEX functions
exe for embeddable C/C++ executables
lib for embeddable C/C++ libraries
dll for C/C++ dynamic libraries
fcn_name is the name of the first
MATLAB function (alphabetically) at the command line. The
function does not support the following characters in folder names: asterisk
(*), question-mark (?), dollar ($), and pound (#). Note Each time codegen generates the same type of output
for the same code, it removes the files from the previous build. If you want
to preserve files from a previous build, before starting another build, copy
them to a different location. |
-double2single
double2single_cfg_name | Generates single-precision MATLAB code using the settings that the coder.SingleConfig object
double2single_cfg_name specifies.
codegen generates files in the folder
codegen/fcn_name /single . fcn_name
is the name of the entry-point function.
When used with the
-config option, also generates single-precision C/C++
code. codegen generates the single-precision files in the
folder
codegen/target /folder_name .
target can be:
mex for MEX functions
exe for embeddable C/C++ executables
lib for embeddable C/C++ libraries
dll for C/C++ dynamic libraries
folder_name is the
concatenation of fcn_name and
singlesuffix .
singlesuffix
is the suffix that the coder.SingleConfig
property OutputFileNameSuffix specifies. The
single-precision files in this folder also have this suffix.
For
more information, see Generate Single-Precision MATLAB Code. This option is not supported for entry-point functions in namespaces. You
must have Fixed-Point Designer to use this option. |
-float2fixed
float2fixed_cfg_name | When used with the -config option, generates
fixed-point C/C++ code using the settings that the floating-point to
fixed-point conversion configuration object
float2fixed_cfg_name
specifies. codegen generates files in the
folder
codegen/target /fcn_name _fixpt .
target can be:
mex for MEX functions
exe for embeddable C/C++ executables
lib for embeddable C/C++ libraries
dll for C/C++ dynamic libraries
fcn_name is the name of the
entry-point function. When used without the
-config option, generates fixed-point MATLAB code using the settings that the floating-point to fixed-point
conversion configuration object named
float2fixed_cfg_name specifies.
codegen generates files in the folder
codegen/fcn_name /fixpt . You
must set the TestBenchName property of
float2fixed_cfg_name . For
example: fixptcfg.TestBenchName = 'myadd_test'; This
command specifies that myadd_test is the test file for
the floating-point to fixed-point configuration object fixptcfg .For more information, see Convert MATLAB Code to Fixed-Point C Code. This option is not
supported for entry-point functions in namespaces. You must have Fixed-Point Designer to use this option. |
-g | Specify whether to use the debug option for the C compiler. If you
enable debug mode, the C compiler disables some optimizations. The compilation
is faster, but the execution is slower. |
-globals
global_values | Specify names and initial values for global variables in MATLAB files. global_values is a cell
array of global variable names and initial values. The format of
global_values
is:
{g1, init1, g2, init2, ..., gn, initn} gn
is the name of a global variable specified as a character vector.
initn is the initial value. For
example:
Alternatively,
use this
format: -globals {global_var, {type, initial_value}} type
is a type object. To create the type object, use
coder.typeof . For global cell array variables, you must
use this format.
Before generating code with
codegen , initialize global variables. If you do not
provide initial values for global variables using the
-globals option, codegen checks for
the variable in the MATLAB global workspace. If you do not supply an initial value,
codegen generates an error. MATLAB
Coder and MATLAB each have their own copies of global data. For consistency,
synchronize their global data whenever the two interact. If you do not
synchronize the data, their global variables can differ. To
specify a constant value for a global variable, use
coder.Constant . For example:
-globals {'g', coder.Constant(v)} specifies
that g is a global variable with constant value
v .For more information, see Generate Code for Global Data. |
-gpuprofile | Enable GPU profiling of the generated code by using GPU
performance analyzer. The GPU
performance analyzer runs a MEX function or
a software-in-the-loop (SIL) execution that collects metrics on CPU and GPU
activities in the generated code. The GPU
performance analyzer provides a report
containing a chronological timeline plot that you can use to visualize,
identify, and mitigate performance
bottlenecks in the generated CUDA® code. To generate and profile CUDA code using a single command, run codegen with
both the -gpuprofile and -test
options. GPU profiling requires the GPU Coder™ product. To profile non-MEX targets, you also need the
Embedded Coder product. For more information, see GPU Performance Analyzer (GPU Coder). |
-I include_path | Add include_path to the beginning of the
code generation path. When codegen searches for
MATLAB functions and custom C/C++ files, it searches the code
generation path first. It does not search for classes on the code generation
path. Classes must be on the MATLAB search path. For more information, see Paths and File Infrastructure Setup. If the path contains characters that are not 7-bit ASCII, such
as Japanese characters, it is possible that codegen does
not find files on this path. To include multiple paths, use
-I before each path you want to include. Enclose paths
containing spaces in single quotes. For example:
-I C:\Project -I 'C:\Custom Files'
|
-jit | Use just-in-time (JIT) compilation for generation of a MEX function.
JIT compilation can speed up MEX function generation. This option applies only
to MEX function generation. This option is not compatible with certain code
generation features or options, such as custom code or using the OpenMP
library. |
-lang:c | Specify the language to use in the generated code as
C. If you do not specify any
target language, the code generator produces C code. |
-lang:c++ | Specify the language to use in the generated code as
C++. |
-launchreport | Generate and open a code generation report. If you do not specify
this option, codegen generates a report only if error or
warning messages occur or if you specify the -report
option. |
-o output_file_name | Generate the MEX function, C/C++ library, or C/C++ executable file
with the base name output_file_name plus an extension:
.a or .lib for C/C++ static
libraries
.exe or no
extension for C/C++ executables
.dll for C/C++ dynamic libraries on Microsoft®
Windows® systems .so for C/C++ dynamic libraries on Linux® systems
.dylib for C/C++ dynamic libraries on Mac
systems
Platform-dependent extension for generated MEX functions
output_file_name can be
a file name or include an existing path.
output_file_name must not contain spaces, as
spaces can lead to code generation failures in certain operating system
configurations.
For MEX functions,
output_file_name must be a valid MATLAB function name. If you do not specify an output file
name for libraries and executables, the base name is
fcn_1 . fcn_1 is the
name of the first MATLAB function specified at the command line. For MEX functions, the
base name is fcn_1_mex . You can run the original
MATLAB function and the MEX function and compare the
results. |
-O
optimization_option | Optimize generated code, based on the value of
optimization_option :
enable:inline — Enable function
inlining.
disable:inline — Disable function
inlining. To learn more about function inlining, see Control Inlining to Fine-Tune Performance and Readability of Generated Code.
enable:openmp — Use OpenMP library if
available. Using the OpenMP library, the MEX functions or C/C++ code
that codegen generates for
parfor -loops can run on multiple threads.
disable:openmp — Disable OpenMP library.
With OpenMP disabled, codegen treats
parfor -loops as for -loops and
generates a MEX function or C/C++ code that runs on a single thread. See
Control Compilation of parfor-Loops.
Specify-O at the command line
once for each optimization. If not specified,
codegen uses inlining and OpenMP for
optimization. |
-package
zip_file_name | Package generated standalone code and its dependencies into a
compressed ZIP file with name zip_file_name . You
can then use the ZIP file to relocate, unpack, and rebuild the code files in
another development environment. This packaging functionality is
also provided by the packNGo function. |
-preservearraydims | Generate code that uses N-dimensional indexing. For more information,
see Generate Code That Uses N-Dimensional Indexing. |
-profile | Enable profiling of generated MEX function by using the MATLAB Profiler. For more information, see Profile MEX Functions by Using MATLAB Profiler. This option is not supported for CUDA code generation using GPU Coder. To profile generated CUDA code, use the -gpuprofile
option. |
-report | Produce a code generation report. If you do not specify this option,
codegen produces a report only if error or warning
messages occur or if you specify the -launchreport
option. If you have Embedded Coder, this option also enables production of the Code Replacements
report. |
-reportinfo info | Export information about code generation to the variable
info in your base MATLAB workspace. See Access Code Generation Report Information Programmatically. |
-rowmajor | Generate code that uses row-major array layout. Column-major layout
is the default. For more information, see Generate Code That Uses Row-Major Array Layout. |
-silent | If code generation succeeds without warning, suppress
all messages, including when you generate a
report. Warning and error messages are displayed. |
-singleC | Generate single-precision C/C++ code. For more information, see Generate Single-Precision C Code at the Command Line. This option is not supported for entry-point functions in
namespaces. You must have Fixed-Point Designer to use this option. |
-std:language_standard | Generate C/C++ code compatible with the specified language standard.
C++ language standards are only supported if the target language is
C++. language_standard is one of these values:
For example, to generate code compatible with the
C++14 (ISO) language standard, use this
option: For
details of the supported language standards, see Change Language Standard Used for Code Generation. |
-test test_file | Run test_file , replacing a call to the
original MATLAB function with a call to the MEX function. Using this option is
the same as running coder.runTest . This
option is supported only when generating MEX functions or when using a
configuration object with VerificationMode set to
'SIL' or 'PIL' . Creation of a
configuration object that has the VerificationMode
parameter requires the Embedded Coder product. |
-toproject
project_file_name | Convert the codegen command to an equivalent
MATLAB
Coder project file named project_file_name .
You can then generate code from the project file by using another
codegen command or the MATLAB
Coder app. You can also use the
-toproject option to convert an incomplete
codegen command to a project file. For example, to
create a project file myProjectTemplate.prj that contains
only the code generation parameters stored in the configuration object
cfg ,
run: In
this case, myProjectTemplate.prj does not contain
specifications of entry-point functions or input types. So, you cannot
generate code from this project file. You can open
myProjectTemplate.prj in the MATLAB
Coder app and use it as a template to create full project files that
you can use to generate code.Running codegen
with the -toproject
project_file_name option does not
generate code. It creates only the project file. See Convert codegen Command to Equivalent MATLAB Coder Project. |
-v | Enable verbose mode to show code generation status and target build
log messages. |
-? | Display help for codegen command. |