Simplify Compilation Using Macros
Macros
The mcc
function, through its exhaustive
set of options, allows you to customize the behavior of a compiled component. If you want a
simplified approach to compilation, you can use a macro to quickly
accomplish basic compilation tasks. Macros let you group several options together to perform
a particular type of compilation.
This table shows the relationship between the macro approach to accomplish a standard compilation and the multioption alternative.
Macro | Bundle | Creates | Option Equivalence
|
---|---|---|---|
-l | macro_option_l | Library | -W lib -T link:lib |
-m | macro_option_m | Standalone application | -Wmain-Tlink:exe |
Working With Macros
The -m
option tells the compiler to produce a standalone application.
The -m
macro is equivalent to the series of options
-W main -T link:exe
This table shows the options that compose the -m
macro and the
information that they provide to the compiler.
-m Macro
Option | Function |
---|---|
-W main | Produce a wrapper file suitable for a standalone application. |
-T link:exe | Create an executable link as the output. |
Changing Macros
You can change the meaning of a macro by editing the corresponding
macro_option
file in
. For
example, to change the matlabroot
\toolbox\compiler\bundles-m
macro, edit the file
macro_option_m
in the bundles
folder.
Note
This changes the meaning of -m
for all users of this MATLAB® installation.
Specifying Default Macros
As the MCCSTARTUP
functionality has been replaced by bundle
technology, the macro_default
file that resides in
toolbox\compiler\bundles
can be used to specify default options to
the compiler.
For example, adding -mv
to the macro_default
file causes the command:
mcc foo.m
mcc -mv foo.m
-v
to the macro_default
file causes the command:
mcc -W 'lib:libfoo' -T link:lib foo.m
mcc -v -W 'lib:libfoo' -T link:lib foo.m