| Contents | Index |
| On this page… |
|---|
mcc is the MATLAB command that invokes MATLAB Compiler. You can issue the mcc command either from the MATLAB command prompt (MATLAB mode) or the DOS or UNIX command line (standalone mode).
You may specify one or more MATLAB Compiler option flags to mcc. Most option flags have a one-letter name. You can list options separately on the command line, for example,
mcc -m -v myfun
Macros are MathWorks supplied MATLAB Compiler options that simplify the more common compilation tasks. Instead of manually grouping several options together to perform a particular type of compilation, you can use a simple macro option. You can always use individual options to customize the compilation process to satisfy your particular needs. For more information on macros, see Using Macros to Simplify Compilation.
You can group options that do not take arguments by preceding the list of option flags with a single dash (-), for example:
mcc -mv myfun
Options that take arguments cannot be combined unless you place the option with its arguments last in the list. For example, these formats are valid:
mcc -v -W main -T link:exe myfun % Options listed separately mcc -vW main -T link:exe myfun % Options combined
This format is not valid:
mcc -Wv main -T link:exe myfun
In cases where you have more than one option that takes arguments, you can only include one of those options in a combined list and that option must be last. You can place multiple combined lists on the mcc command line.
If you include any C or C++ file names on the mcc command line, the files are passed directly to mbuild, along with any MATLAB Compiler generated C or C++ files.
If you use conflicting options, MATLAB Compiler resolves them from left to right, with the rightmost option taking precedence. For example, using the equivalencies in Macro Options,
mcc -m -W none test.m
is equivalent to:
mcc -W main -T link:exe -W none test.m
In this example, there are two conflicting -W options. After working from left to right, MATLAB Compiler determines that the rightmost option takes precedence, namely, -W none, and the product does not generate a wrapper.
Caution Macros and regular options may both affect the same settings and may therefore override each other depending on their order in the command line. |
The valid, recommended file extension for a file submitted to MATLAB Compiler is .m. Always specify the complete file name, including the .m extension, when compiling with mcc or you may encounter unpredictable results.
Note P-files (.p) have precedence over MATLAB files, therefore if both P-files and MATLAB files reside in a folder, and a file name is specified without an extension, the P-file will be selected. |
To designate code to be compiled with C or C++, rewrite the C or C++ function as a MEX-file and simply call it from your application. The %#EXTERNAL pragma is no longer supported.
You can control whether the MEX-file or a MATLAB stub gets called by using the isdeployed function.
When coding, keep in mind that LCC compilers can be more strict in enforcing bool return types from C and void returns from C++ than Microsoft compilers.
To avoid potential problems, ensure all C methods you write (and reference from within MATLAB code) return a bool return type indicating the status. C++ methods should return nothing (void).
![]() | Compiler Commands | Using Macros to Simplify Compilation | ![]() |

Learn how to build standalone executables and C/C++ shared libraries from MATLAB code.
| © 1984-2012- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |