Package COM Components from Command Line
You can package COM components at the MATLAB® prompt or your system prompt using either of these commands.
Execute Compiler Projects with
deploytool command has two flags that invoke one of the compiler apps
to package an already existing project without opening a window.
-build— Invoke the correct compiler app to build the project but not generate an installer.
-package— Invoke the correct compiler app to build the project and generate an installer.
deploytool -package magicsquare generates
the binary files defined by the
and packages them into an installer that you can distribute to others.
Create COM Component with
mcc command invokes MATLAB
Compiler to create a COM component at the command prompt and provides
fine-level control while packaging the component. It does not package the results in
A MATLAB class cannot be directly packaged into a COM object. You can, however,
use a user-generated class inside a MATLAB file and build a COM object from that file. You can use the
MATLAB command-line interface instead of the Library Compiler app to create
COM objects. Do this by issuing the
mcc command with options. If
mcc, you do not create a project.
The following table provides an overview of some
related to components, along with syntax and examples of their usage.
|Action to Perform||Description|
|Create component that has one class.|
The example creates a COM
Add additional classes to a COM component.
A separate COM named
example creates a COM component named
|Simplify the command-line input for components.|
Uses the bundle.
|Control how each COM class uses the MATLAB Runtime.|
default, a new MATLAB Runtime instance is created for each instance of each COM
class in the component. Use
This option tells the compiler to create a single MATLAB Runtime at the time when the first COM class is instantiated. This MATLAB Runtime is reused and shared among all subsequent class instances, resulting in more efficient memory usage and eliminating the MATLAB Runtime startup cost in each subsequent class instantiation.
The default behavior dictates that a new MATLAB Runtime be created for each instance of a class, so
when the class is destroyed, the MATLAB Runtime is destroyed as well. If you want to retain
the state of global variables (such as those allocated for
drawing figures, for instance), use the
The example creates a COM component
When multiple instances of this class are instantiated in an application, only one MATLAB Runtime is initialized, and it is shared by each instance.
|Create subfolders needed for deployment and copy associated files to them.|
Differences Between Compiler Apps and Command Line
You perform the same functions using the compiler apps, a
function, or the
mcc command-line interface. The interactive menus and
dialog boxes used in the compiler apps build
mcc commands that are
customized to your specification. As such, your MATLAB code is processed the same way as if you were packaging it using
If you know the commands for the type of application you want to deploy and do not require
an installer, it is faster to execute either
mcc than go through the compiler app workflow.
Compiler app advantages include:
You can perform related deployment tasks with a single intuitive interface.
You can maintain related information in a convenient project file.
Your project state persists between sessions.
You can load previously stored compiler projects from a prepopulated menu.
You can package applications for distribution.