MATLAB Compiler | ![]() ![]() |
Common Uses of the Compiler
This section summarizes how to use the MATLAB Compiler to generate some of its more standard results. The first four examples take advantage of the macro options.
Create a MEX-File. To translate an M-file named mymfile.m
into C and to create the corresponding C MEX-file that can be called directly from MATLAB, use
mcc -x mymfile
Create a Simulink S-Function. To translate an M-file named mymfile.m
into C and to create the corresponding Simulink S-function using dynamically sized inputs and outputs, use
mcc -S mymfile
Create a Stand-Alone C Application. To translate an M-file named mymfile.m
into C and to create a stand-alone executable that can be run without MATLAB, use
mcc -m mymfile
Create a Stand-Alone C++ Application. To translate an M-file named mymfile.m
into C++ and to create a stand-alone executable that can be run without MATLAB, use
mcc -p mymfile
Create a Stand-Alone C Graphics Library Application. To translate an M-file named mymfile.m
that contains Handle Graphics functions into C and to create a stand-alone executable that can be run without MATLAB, use
mcc -B sgl mymfile
Create a Stand-Alone C++ Graphics Library Application. To translate an M-file named mymfile.m
that contains Handle Graphics functions into C++ and to create a stand-alone executable that can be run without MATLAB, use
mcc -B sglcpp mymfile
Create a C Library. To create a C library, use
mcc -m -W lib:libfoo -T link:lib foo.m
Create a C++ Library. To create a C++ library, use
mcc -p -W lib:libfoo -T compile:lib foo.m
Create a C Shared Library. To create a C shared library that performs specialized calculations that you can call from your own programs, use
mcc -W lib:mylib -L C -t -T link:lib -h Function1 Function2 ...
Create MATLAB P-Code. To translate an M-file named mymfile.m
into MATLAB P-code, use
mcc -B pcode mymfile
![]() | MATLAB Compiler Option Flags | mcc | ![]() |