You can create standalone applications at the MATLAB® prompt or your system command prompt using any of the following commands:
The mcc
command can be directly invoked from both the MATLAB command prompt and a system command prompt.
compiler.build.standaloneApplication
The compiler.build.standaloneApplication
function can be directly
invoked from the MATLAB command prompt. However, to run this function from a system command prompt, you
need to use the matlab
function with the -batch
option.
compiler.build.standaloneWindowsApplication
The compiler.build.standaloneWindowsApplication
function can be
directly invoked from the MATLAB command prompt. However, to run this function from a system command prompt, you
need to use the matlab
function with the -batch
option.
mcc
CommandThe mcc
command invokes MATLAB
Compiler™ to create a deployable application at the command prompt and provides fine-level
control while packaging the application. It does not package the results in an installer.
To invoke the compiler to generate an application, use mcc
with either
the -m
or the -e
flag. Both flags package a MATLAB function and generate a standalone executable. The -m
flag
creates a standard executable that runs at a system command line.
On the Windows® operating system, the -e
flag generates an executable that does
not open a Command Prompt window when double-clicked from the Windows File Explorer.
Use the following mcc
options to package standalone
applications.
Option | Description |
---|---|
-W main -T link:exe | Generate a standard executable equivalent to using -m . |
-W WinMain -T link:exe | Generate an executable that does not open a command prompt when double-clicked from
Windows file explorer. It is equivalent to using -e . |
-a | Add any files on the path to the generated binaries. |
-d | Specify the folder for the packaged applications. |
-o | Specify the name of the generated executable file. |
compiler.build.standaloneWindowsApplication
FunctionTo create a standalone application from the Windows Command Prompt using the
compiler.build.standaloneWindowsApplication
function, you need to use the
matlab
function with the -batch
option. For
example:
matlab -batch
compiler.build.standaloneWindowsApplication('mymagic.m') |
To run your standalone application:
Open a terminal window.
Navigate to the folder into which you packaged your standalone application.
Run the application using one of the following commands:
Windows | magicsquare 5 |
macOS | First, set the
Now run the application:
|
Linux® | ./ magicsquare 5 |
A 5-by-5 magic square is displayed in the console:
17 24 1 8 15 23 5 7 14 16 4 6 13 20 22 10 12 19 21 3 11 18 25 2 9
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.