Documentation

This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English version of the page.

Note: This page has been translated by MathWorks. Click here to see
To view all translated materials including this page, select Country from the country navigator on the bottom of this page.

Create Standalone Application from Command Line

You can package 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 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 project_name — Invoke the correct compiler app to build the project but 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 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 Windows®, the -e flag generates an executable that does not open a command prompt when double-clicked from Windows file explorer.

Use the following mcc options to package 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 Windows file explorer. It is equivalent to using -e.
-a filePathAdd any files on the path to the generated binaries.
-d outFolderSpecify the folder for the packaged applications.
-o fileNameSpecify the name of the generated executable file.

Run MATLAB Generated Standalone Application

To run your standalone application:

  1. Open a terminal window.

  2. Navigate to the folder into which you packaged your standalone application.

  3. Run the application using one of the following commands:

    Windows magicsquare 5
    Mac OS X

    You must set the DYLD_LIBRARY_PATH environment variable in the command window for the standalone application to work as follows:

    $export DYLD_LIBRARY_PATH = MCR_ROOT/v92/runtime/maci64:MCR_ROOT/v92/sys/os/maci64:MCR_ROOT/v92/bin/maci64

    Now run the application:

    ./magicsquare.app/Contents/MacOS/magicsquare 5
    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

Differences Between Compiler Apps and Command Line

You perform the same functions using either the compiler apps 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 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.

See Also

|

Related Topics