Create Standalone Application from Command Line

You can compile standalone applications 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 compile code at the prompt.

Execute Compiler Projects with deploytool

The deploytool command has two flags to invoke one of the compiler apps without opening a window.

  • -build project_name — Invoke the correct compiler app to build the project and not generate an installer.

  • -package project_name — Invoke the correct compiler app to build the project and generate an installer.

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 Standalone Application with mcc

The mcc command invokes the MATLAB compiler to compile code at the prompt and provides fine-level control compiling an 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 compile a MATLAB function and generate a standalone executable. The -m flag creates a standard executable that runs at a system command line. On Windows®, the-e flag generates an executable that does not open a command prompt when double-clicked from the Windows file explorer.

Use the following mcc options to compile standalone applications.

OptionDescription
-W main -T link:exeGenerate a standard executable equivalent to using -m.
-W WinMain -T link:exeGenerate an executable that does not open a command prompt when double-clicked from the Windows file explorer equivalent to using -e.
-a filePathAdd any files on the path to the generated binaries.
-d outFolderSpecify the folder for the compiled applications.
-o fileNameSpecify the name of the generated executable file.
Was this topic helpful?