Package COM Components from Command Line
You can package COM components at the MATLAB® prompt or your system prompt using either of these commands.
deploytool
invokes the Application Compiler app to execute a saved compiler project.mcc
invokes the MATLAB Compiler™ to create a deployable application at the command prompt.
Execute Compiler Projects with deploytool
The 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.project_name
-package
— Invoke the correct compiler app to build the project and generate an installer.project_name
For example, deploytool -package magicsquare
generates
the binary files defined by the magicsquare
project
and packages them into an installer that you can distribute to others.
Create COM Component with mcc
The 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
an installer.
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
you use mcc
, you do not create a project.
The following table provides an overview of some mcc
options
related to components, along with syntax and examples of their usage.
Action to Perform | Description |
---|---|
Create component that has one class. |
The
|
Syntax
An unspecified
| |
Example
The example creates a COM
component called | |
Add additional classes to a COM component. |
A separate COM named
Following the
|
Syntax
| |
Example
The
example creates a COM component named
| |
Simplify the command-line input for components. |
Uses the bundle. |
Syntax
| |
Example
| |
Control how each COM class uses the MATLAB Runtime. |
By
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. When using Note 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
|
Example
The example creates a COM component
called 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. |
The |
Syntax
|
Differences Between Compiler Apps and Command Line
You perform the same functions using the compiler apps, a compiler.build
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
mcc
.
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 compiler.build
or
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.