Skip to Main Content Skip to Search
Product Documentation

mcc - Invoke MATLAB Compiler

Syntax

mcc -win32 [-W | -K | -S] 'java:component_name,class_name,
file1[file2...fileN]
[class{class_name:file1 [,file2,...,fileN]},...]
[-d output_dir_path]

mcc -win32 -B 'bundlefile'[:arg1, arg2, ..., argN]


Description

Use the mcc command to invoke the MATLAB Compiler product either from the MATLAB command prompt (MATLAB mode) or the DOS or UNIX command line (standalone mode).

mcc prepares MATLAB file(s) for deployment outside of the MATLAB environment.

Options

-W

The -W option is used when running mcc with the MATLAB Builder JA product to create a class encapsulating one or more MATLAB files.

-W String ElementsDescription
java:Keyword that tells the compiler the type of component to create, followed by a colon. Specify java: to create a Java component.
component_nameSpecifies the name of the component and its namespace, which is a period-separated list, such as companyname.groupname.component.
class_nameSpecifies the name of the Java class to be created. The default class_name is the last item in the list specified as component_name.

file1 [file2...fileN] are MATLAB files to be encapsulated as methods in class_name.

[class{class_name:file1 [,file2,...,fileN]},...]Optional. Specifies additional classes that you want to include in the component. To use this option, you specify the class name, followed by a colon, and then the names of the files you want to include in the class. You can include this multiple times to specify multiple classes.
[-d output_dir_path]Optional. Tells the builder to create a folder and copy the output files to it. If you use mcc instead of the Deployment Tool, the project_folder\src and project_folder\distrib folders are not automatically created.

    Note   By default, a new MCR instance is created for each instance of each Java class in the component. Use -S to change the default.

    The -S option lets you control how each Java class uses the MCR. It tells the builder to create a single MCR when the first Java class is instantiated. It causes all initializations to share a single MCR instance, eliminating the startup cost associated with spawning another MCR instance.

    When using -S, note that all class instances share a single MATLAB workspace and share global variables in the MATLAB files used to build the component. This makes properties of a Java class behave as static properties instead of instance-wise properties.

-K

Directs mcc to not delete output files if the compilation ends prematurely, due to error.

mcc's default behavior is to dispose of any partial output if the command fails to execute successfully.

-B

The -B option is used to simplify the command-line input.

-B

The -B option tells the builder to replace a specified file with the command-line information it contains.

-B String ElementsDescription
java:Keyword that tells the compiler the type of component to create, followed by a colon. Specify java: to create a Java component.
bundlefileSpecifies the name of the file containing predefined component and class information.
[:arg1, arg2, ..., argN]Files or other arguments used by the bundlefile.

Examples

Using -W with One Class

mcc -W 'java:com.mycompany.mycomponent,myclass' 
     foo.m bar.m

The example creates a Java component that has a fully qualified package name, com.mycompany.mycomponent. The component contains a single Java class, myclass, which contains methods foo and bar.

To use myclass, place the following statement in your code:

import com.mycompany.mycomponent.myclass;

Using -W with Additional Classes

mcc -W 'java:com.mycompany.mycomponent,myclass' 
    foo.m bar.m class{myclass2:foo2.m,bar2.m}

The example creates a Java component named mycomponent with two classes:

myclass has methods foo and bar.
myclass2 has methods foo2 and bar2.

Using -B to Simplify Command Input

Suppose myoptions file contains

-W 'java:mycomponent,myclass'

In this case,

mcc -B 'myoptions' foo.m bar.m 

produces the same results as

mcc -W 'java:[mycomponent,myclass]' foo.m bar.m

Using -S to Initialize a Single MCR

mcc -S -W 'java:mycomponent,myclass' foo.m bar.m

The example creates a Java component called mycomponent containing a single Java class named myclass with methods foo and bar. (See the first example in this table)

If and when multiple instances of myclass are instantiated in an application, only one MCR is initialized, and it is shared by all instances of myclass.

-win32 Run in 32-Bit Mode

Use this option to build a 32-bit application on a 64-bit system only when the following are both true:

  


Recommended Products

Includes the most popular MATLAB recorded presentations with Q&A sessions led by MATLAB experts.

 © 1984-2012- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS