Main Content

Invoke MATLAB Build Options

Specify Full Path Names to Build MATLAB Code

If you specify a full path name to a MATLAB® file on the mcc command line, the compiler

  1. Breaks the full name into the corresponding path name and file names (<path> and <file>).

  2. Replaces the full path name in the argument list with “-I <path> <file>”.

Specifying Full Path Names

For example:

mcc -m /home/user/myfile.m

would be treated as

mcc -m -I /home/user myfile.m

In rare situations, this behavior can lead to a potential source of confusion. For example, suppose you have two different MATLAB files that are both named myfile.m and they reside in /home/user/dir1 and /home/user/dir2. The command

mcc -m -I /home/user/dir1 /home/user/dir2/myfile.m

would be equivalent to

mcc -m -I /home/user/dir1 -I /home/user/dir2 myfile.m

The compiler finds the myfile.m in dir1 and compiles it instead of the one in dir2 because of the behavior of the -I option. If you are concerned that this might be happening, you can specify the -v option and then see which MATLAB file the compiler parses. The -v option prints the full path name to the MATLAB file during the dependency analysis phase.


The compiler produces a warning (specified_file_mismatch) if a file with a full path name is included on the command line and the compiler finds it somewhere else.

Using Bundles to Build MATLAB Code

Bundles provide a convenient way to group sets of compiler options and recall them as needed. The syntax of the bundle option is:

-B <bundle>[:<a1>,<a2>,...,<an>]

where bundle is either a predefined string such as cpplib or csharedlib or the name of a file that contains a set of mcc command-line options, arguments, filenames, and/or other -B options.

A bundle can include replacement parameters for compiler options that accept names and version numbers. For example, the bundle for C shared libraries, csharedlib, consists of:

-W lib:%1% -T link:lib

To invoke the compiler to produce the C shared library mysharedlib use:

mcc -B csharedlib:mysharedlib myfile.m myfile2.m

In general, each %n% in the bundle will be replaced with the corresponding option specified to the bundle. Use %% to include a % character. It is an error to pass too many or too few options to the bundle.


You can use the -B option with a replacement expression as is at the DOS or UNIX® prompt. If more than one parameter is passed, you must enclose the expression that follows the -B in single quotes. For example,

>>mcc -B csharedlib:libtimefun weekday data tic calendar toc 

can be used as is at the MATLAB prompt because libtimefun is the only parameter being passed. If the example had two or more parameters, then the quotes would be necessary as in

>>mcc -B 'cexcel:component,class,1.0' ...
weekday data tic calendar toc

Available Bundle Files

Bundle File




C++ library

-W cpplib:library_name -T link:lib

C library

-W lib:library_name -T link:lib
ccomCOM component -W com:component_name,className,version -T link:lib
cexcelExcel Add-in-W excel:addin_name,className,version -T link:lib
cjavaJava® package-W java:packageName,className
dotnet.NET assembly

-W dotnet:assembly_name,className,framework_version,security,remote_type -T link:lib