Documentation

Simplify Compilation Using Macros

Macros

The compiler, through its exhaustive set of options, gives you access to the tools you need to do your job. If you want a simplified approach to compilation, you can use one simple macro that allows you 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

Function Wrapper |Output Stage ||

-lmacro_option_l

Library

-W lib -T link:lib
-mmacro_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 matlabroot\toolbox\compiler\bundles. For example, to change the -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
to execute as though it were:
mcc -mv foo.m
Similarly, adding -v to the macro_default file causes the command:
mcc -W 'lib:libfoo' -T link:lib foo.m
to behave as though the command were:
mcc -v -W 'lib:libfoo' -T link:lib foo.m