Products & Services Solutions Academia Support User Community Company

Learn more about MATLAB Compiler   

Deploying to End Users

Steps by the Programmer to Deploy to End Users

For an end user to run an application or use a library that contains compiled M-code, there are two sets of tasks. Some tasks are for the programmer who developed the application or library, and some tasks are for the end user.

  1. Create a package that contains the software needed at run time. See What Software Does a Programmer Need? for more details.

      Note   The package needed for end users must include the .ctf file, which includes all the files in your preferences folder. Thus, you should make sure that you do not have files in your preferences folder that you do not want to expose to end users. MATLAB preferences set at compile time are inherited by a compiled application. Preferences set by a compiled application do not affect the MATLAB preferences, and preferences set in MATLAB do not affect a compiled application until that application is recompiled.

      The preferences folder is as follows:

      • $HOME/.matlab/current_release on UNIX

      • system root\profiles\user\application data\mathworks\
        matlab\current_release
        on Windows

      The folder will be stored in the CTF archive in a folder with a generated name, such as:

      mwapplication_mcr/myapplication_7CBEDC3E1DB3D462C18914C13CBFA649.

      Caution   MATLAB does not save your preferences folder until you exit MATLAB. Therefore, if you change your MATLAB preferences, stop and restart MATLAB before attempting to recompile using your new preferences.

      Note   The package needed for end users must include the .ctf file, which includes all the files in your preferences folder. Thus, you should make sure that you do not have files in your preferences folder that you do not want to expose to end users. MATLAB preferences set at compile time are inherited by a compiled application. Preferences set by a compiled application do not affect the MATLAB preferences, and preferences set in MATLAB do not affect a compiled application until that application is recompiled.

      The preferences folder is as follows:

      • $HOME/.matlab/current_release on UNIX

      • system root\profiles\user\application data\mathworks\
        matlab\current_release
        on Windows

      The folder will be stored in the CTF archive in a folder with a generated name, such as:

      mwapplication_mcr/myapplication_7CBEDC3E1DB3D462C18914C13CBFA649.

      Caution   MATLAB does not save your preferences folder until you exit MATLAB. Therefore, if you change your MATLAB preferences, stop and restart MATLAB before attempting to recompile using your new preferences.

  2. Write instructions for the end user. See Steps by the End User.

  3. Distribute the package to your end user, along with the instructions.

Steps by the End User

  1. Open the package containing the software needed at run time.

  2. Run MCRInstaller once on the target machine, that is, the machine where you want to run the application or library. The MCRInstaller opens a command window and begins preparation for the installation. See Using the MCR Installer GUI.

  3. If you are deploying a Java application to end users, they must set the class path on the target machine.

Using the MCR Installer GUI

  1. When the MCR Installer wizard appears, click Next to begin the installation. Click Next to continue.

  2. In the Select Installation Folder dialog box, specify where you want to install the MCR and whether you want to install the MCR for just yourself or others. Click Next to continue.

      Note   The Install MATLAB Compiler Runtime for yourself, or for anyone who uses this computer option is not implemented for this release. The current default is Everyone.

  3. Confirm your selections by clicking Next.

    The installation begins. The process takes some time due to the quantity of files that are installed.

    The MCRInstaller automatically:

    • Copies the necessary files to the target folder you specified.

    • Registers the components as needed.

    • Updates the system path to point to the MCR binary folder, which is <target_directory>/<version>/runtime/win32|win64.

  4. When the installation completes, click Close on the Installation Completed dialog box to exit.

What Software Does the End User Need?

The software required by end users depends on which of the following kinds of software is to be run by the user:

Standalone Compiled Application That Accesses Shared Library

To distribute a shared library created with MATLAB Compiler to end users, create a package that includes the following files.

Component

Description

MCRInstaller.exe
(Windows)

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

matrixdriver.exe
(Windows)

matrixdriver
(UNIX)

Application

libmatrix

Shared library; extension varies by platform. Extensions are:

  • Windows — .dll

  • Solaris, Linux, Linux x86-64 — .so

  • Mac OS X — .dylib

.NET Application

To distribute a .NET application that uses components created with MATLAB Builder NE, create a package that includes the following files.

Software ModuleDescription
componentName.xmlDocumentation files
componentName.pdb
(if Debug option is selected)
Program Database File, which contains debugging information
componentName.dll

Component assembly file

MCRInstaller.exeMCR Installer (if not already installed on the target machine)
application.exe

Application

COM Application

To distribute a COM application that uses components created with MATLAB Builder NE or MATLAB Builder EX, create a package that includes the following files.

Software ModuleDescription
componentname.ctf

Component Technology File (ctf) archive. This is a platform-dependent file that must correspond to the end user's platform.

componentname
_version
.dll

Component that contains compiled M-code

_install.bat

Script run by the self-extracting executable

MCRInstaller.exe

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

MCRInstaller.exe installs MATLAB Compiler Runtime (MCR), which users of your component need to install on the target machine once per release.

application.exe

Application

Java Application

To distribute a Java application created with MATLAB Builder JA, create a componentname.jar file. To deploy the application on computers without MATLAB, you must include the MCR when creating your Java component.

Microsoft Excel Add-In

To distribute an Excel add-in created with MATLAB Builder EX, create a package that includes the following files.

Software ModuleDescription
componentname
_version
.dll

Component that contains compiled M-code

_install.bat

Script run by the self-extracting executable

MCRInstaller.exe

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

*.xla

Any Excel add-in files found in projectdirectory\distrib

Using Relative Paths with Project Files

Project files now support the use of relative paths as of R2007b of MATLAB Compiler, enabling you to share a single project file for convenient deployment over the network. Simply share your project folder and use relative paths to define your project location to your distributed computers.

Porting Generated Code to a Different Platform

You can distribute an application generated by MATLAB Compiler 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 the Windows version of MATLAB Compiler to build the application on a Windows machine.

To deploy an application to a machine with an operating system different from the machine used to develop the application, you must rebuild the application on the desired targeted platform. For example, if you want to deploy a previous application developed on a Windows machine to a Linux machine, you must use MATLAB Compiler on a Linux machine and completely rebuild the application. You must have a valid MATLAB Compiler license on both platforms to do this.

Extracting a CTF Archive Without Executing the Component

CTF archives contain content (M-files and MEX-files) that need to be extracted from the archive before they can be executed. In order to extract the archive you must override the default CTF embedding option (see Overriding Default CTF Archive Embedding Using the MCR Component Cache). To do this, ensure that you compile your component with the -C Do Not Embed CTF Archive by Default option.

The CTF archive automatically expands the first time you run a MATLAB Compiler-based component (a MATLAB Compiler based standalone application or an application that calls a MATLAB Compiler-based shared library, COM, or .NET component).

To expand an archive without running the application, you can use the extractCTF (.exe on Windows) standalone utility provided in the matlabroot/toolbox/compiler/deploy/arch folder, where arch is your system architecture, Windows = win32|win64, Linux = glnx86, Solaris = sol64, x86-64 = glnxa64, and Mac OS X = mac. This utility takes the CTF archive as input and expands it into the folder in which it resides. For example, this command expands hello.ctf into the folder where it resides:

extractCTF hello.ctf

The archive expands into a folder called hello_mcr. In general, the name of the folder containing the expanded archive is <componentname>_mcr, where componentname is the name of the CTF archive without the extension.

Dependency Analysis Function (depfun) and User Interaction with the Compilation Path

MATLAB Compiler uses a dependency analysis function (depfun) to determine the list of necessary files to include in the CTF package. In some cases, this process includes an excessive number of files, for example, when MATLAB object classes are included in the compilation and it cannot resolve overloaded methods at compile time. The dependency analysis is an iterative process that also processes include/exclude information on each pass. Consequently, this process can lead to very large CTF archives resulting in long compilation times for relatively small applications.

depfun searches for "executable" content such as:

depfun does not search for data files of any kind. You must manually include data files.

M-files are encrypted by depfun, and depfun creates authorization files for each MEX-file. This file guards against MEX-files of the same name (but of different functionality) being placed into exploded CTF folders.

The most effective way to reduce the number of files is to constrain the MATLAB path that depfun uses at compile time. MATLAB Compiler includes features that enable you to manipulate the path. Currently, there are three ways to interact with the compilation path:

addpath and rmpath in MATLAB

If you run MATLAB Compiler from the MATLAB prompt, you can use the addpath and rmpath commands to modify the MATLAB path before doing a compilation. There are two disadvantages:

Passing -I <directory> on the Command Line

You can use the -I option to add a folder to the beginning of the list of paths to use for the current compilation. This feature is useful when you are compiling files that are in folders currently not on the MATLAB path.

Passing -N and -p <directory> on the Command Line

There are two MATLAB Compiler options that provide more detailed manipulation of the path. This feature acts like a "filter" applied to the MATLAB path for a given compilation. The first option is -N. Passing -N on the mcc command line effectively clears the path of all folders except the following core folders (this list is subject to change over time):

It also retains all subfolders of the above list that appear on the MATLAB path at compile time. Including -N on the command line allows you to replace folders from the original path, while retaining the relative ordering of the included folders. All subfolders of the included folders that appear on the original path are also included. In addition, the -N option retains all folders that the user has included on the path that are not under matlabroot/toolbox.

Use the -p option to add a folder to the compilation path in an order-sensitive context, i.e., the same order in which they are found on your MATLAB path. The syntax is

p <directory>

where <directory> is the folder to be included. If <directory> is not an absolute path, it is assumed to be under the current working folder. The rules for how these folders are included are

Ensuring Memory for Deployed Applications

If you are having trouble obtaining memory for your deployed application, use MATLAB Memory Shielding for deployed applications to ensure a maximum amount of contiguous allocated memory. See Reserving Memory for Deployed Applications with MATLAB Memory Shielding for more information.

  


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