Deploying Standalone Applications
Compiling the Application
This example takes a MATLAB® file, magicsquare.m,
and creates a standalone application, magicsquare.
Copy the file
magicsquare.mfrommatlabroot\extern\examples\compiler
to your work folder.
To compile the MATLAB code, use
mcc -mv magicsquare.m
The
-moption tells MATLAB Compiler™ (mcc) to generate a standalone application. The-voption (verbose) displays the compilation steps throughout the process and helps identify other useful information such as which third-party compiler is used and what environment variables are referenced.This command creates the standalone application called
magicsquareand additional files. The Windows® platform appends the.exeextension to the name.
Testing the Application
These steps test your standalone application on your development machine.
Note
Testing your application on your development machine is an important
step to help ensure that your application is compilable. To verify
that your application compiled properly, you must test all functionality
that is available with the application. If you receive an error message
similar to Undefined function or Attempt
to execute script script_name as
a function, it is likely that the application will not run
properly on deployment machines. Most likely, your deployable archive
is missing some necessary functions. Use -a to
add the missing functions to the archive and recompile your code.
Update your path as described in Set MATLAB Runtime Path for Deployment.
Run the standalone application from the system prompt (shell prompt on UNIX® or DOS prompt on Windows) by typing the application name.
magicsquare.exe 4 (On Windows) magicsquare 4 (On UNIX) magicsquare.app/Contents/MacOS/magicsquare 4 (On Maci64)
The results are:
ans = 16 2 3 13 5 11 10 8 9 7 6 12 4 14 15 1
Deploying the Application
You can distribute a MATLAB Compiler generated standalone application to any target machine that has the same operating system as the machine on which the application was compiled.
For example, if you want to deploy an application to a Windows machine, you must use MATLAB Compiler to build the application on a Windows machine. If you want to deploy the same application to a UNIX machine, you must use MATLAB Compiler on the same UNIX platform and completely rebuild the application. To deploy an application to multiple platforms requires MATLAB and MATLAB Compiler licenses on all the desired platforms.
Windows
Gather and package the following files and distribute them to the deployment machine.
Component | Description |
|---|---|
| MATLAB Runtime installer | Self-extracting MATLAB Runtime library utility; platform-dependent
file that must correspond to the end user's platform. Run the |
| Application; |
UNIX
Distribute and package your standalone application on UNIX by packaging the following files and distributing them to the deployment machine.
Component | Description |
|---|---|
| MATLAB Runtime installer | MATLAB Runtime library archive; platform-dependent
file that must correspond to the end user's platform. Run the |
| Application |
Maci64
Distribute and package your standalone application on 64-bit Macintosh by copying, tarring, or zipping as described in the following table.
Component | Description |
|---|---|
| MATLAB Runtime installer | MATLAB Runtime library archive; platform-dependent
file that must correspond to the end user's platform. Run the |
| Application |
| Application bundle Assuming
|
Running the Application
These steps describe the process that end users must follow to install and run the application on their machines.
Preparing Your Machines
Install the MATLAB Runtime by running the mcrinstaller command to obtain name
of the executable or binary. For more information on running the MATLAB Runtime installer
utility and modifying your system paths, see MATLAB Runtime.
Executing the Application
Run the magicsquare standalone application
from the system prompt and provide a number representing the size
of the desired magic square, for example, 4.
magicsquare 4
The results are displayed as:
ans =
16 2 3 13
5 11 10 8
9 7 6 12
4 14 15 1
Note
Input arguments you pass to and from a system prompt are treated as string input, and you need to consider that in your application.
Note
Before executing your MATLAB
Compiler generated executable,
set the LD_PRELOAD environment variable to \lib\libgcc_s.so.1.
Executing the Application on 64-Bit Macintosh (Maci64). For 64-bit Macintosh, you run the application through the bundle:
magicsquare.app/Contents/MacOS/magicsquare