Products & Services Industries Academia Support User Community Company

Learn more about MATLAB Compiler   

C Standalone Application Target

Compiling the Application

This example takes an M-file, magicsquare.m, and creates a standalone C application, magicsquare.

  1. Copy the file magicsquare.m from

    matlabroot/extern/examples/compiler
    

    to your work folder.

  2. To compile the M-code, use

    mcc -mv magicsquare.m
    

    The -m option tells MATLAB Compiler (mcc) to generate a C standalone application. The -v option (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 magicsquare and additional files. The Windows platform appends the .exe extension to the name. See the table in Standalone Executable for the complete list of files created.

Testing the Application

These steps test your standalone application on your development machine.

  1. Update your path as described in UNIX Settings for Development and Testing

  2. 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    (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

MCRInstaller.exe

Self-extracting MATLAB Compiler Runtime library utility; platform-dependent file that must correspond to the end user's platform.

magicsquare

Application; magicsquare.exe for Windows

UNIX

Distribute and package your standalone application on UNIX by packaging the following files and distributing them to the deployment machine.

Component

Description

MCRInstaller.bin

MATLAB Compiler Runtime library archive; platform-dependent file that must correspond to the end user's platform

magicsquare

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

MCRInstaller.bin

MATLAB Compiler Runtime library archive; platform-dependent file that must correspond to the end user's platform

magicsquare

Application

magicsquare.app

Application bundle

Assuming foo is a folder within your current folder:

  • Distribute by copying:

    cp -R myapp.app foo
    
  • Distribute by tarring:

    tar -cvf myapp.tar myapp.app 
    cd foo
    tar -xvf../ myapp.tar
    
  • Distribute by zipping:

    zip -ry myapp myapp.app
    cd foo
    unzip ../myapp.zip
    

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

  1. Install the MCR by running the MCRInstaller in a folder. For example, run MCRInstaller.exe in C:\MCR. For more information on running the MCR Installer utility, seeWorking with the MCR and Replacement of MCRInstaller.zip and BUILDMCR Functionality.

  2. See Path Modifications Required for Accessibility for information on setting your path.

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

Executing the Application on 64-Bit Macintosh (Maci64).   For 64-bit Macintosh, you run the application through the bundle:

magicsquare.app/Contents/MacOS/magicsquare

  


Recommended Products

Includes the most popular MATLAB recorded presentations with Q&A sessions led by MATLAB experts.

 © 1984-2009- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS