| Contents | Index |
| On this page… |
|---|
Gathering Files Necessary for Deployment Distribute MATLAB Code Using the MATLAB Compiler Runtime (MCR) |
The C or C++ developer performs these tasks.
C/C++ Developer
| Role | Knowledge Base | Responsibilities |
|---|---|---|
|
|
|
|
Key Tasks for the C or C++ Developer
| Task | Reference |
|---|---|
| Ensure that you have the needed files from the MATLAB programmer before proceeding. | Gathering Files Necessary for Deployment |
| Distribute the files. | Distribute to End Users |
| Install the MCR on target computers by running the MCR Installer. Update system paths on UNIX systems. | Distribute MATLAB Code Using the MATLAB Compiler Runtime (MCR) |
| Ensure that the final standalone application or library executes reliably in the end-user environment. | Build and Test |
Before beginning, verify that you have access to the following files, packaged by the MATLAB programmer in Package Copying (Optional). End users who do not have a copy of MATLAB installed need the following:
MCR Installer. For locations of all MCR Installers, run the mcrinstaller command.
readme.txt file
See Packaging (Optional) for more information about these files.
If the MATLAB programmer packages the standalone or library (see Packaging (Optional)), paste the package in a folder on the target machine, and run it. If you are using an archive file, extract the contents to the target machine.
Note If you are using a non-Windows operating system, "console applications" are referred to as "standalone applications". |
On target computers without MATLAB, install the MCR, if it is not already present on the deployment machine.
The MATLAB Compiler Runtime (MCR) is an execution engine made up of the same shared libraries MATLAB uses to enable the execution of MATLAB files on systems without an installed version of MATLAB.
The MATLAB Compiler Runtime (MCR) is now available for downloading from the Web to simplify the distribution of your applications or components created with the MATLAB® Compiler. Direct your end users to the MATLAB Compiler product page to download the MCR, as opposed to redistributing or packaging it with your applications or components.
In order to deploy a component, you can either package the MCR along with it or simply direct your end users to download it from the Web.
Before you utilize the MCR on a system without MATLAB, run the MCR Installer. Locate the installer my entering the mcrinstaller command from MATLAB.
The installer does the following:
Installs the MCR (if not already installed on the target machine)
Installs the component assembly in the folder from which the installer is run
Copies the MWArray assembly to the Global Assembly Cache (GAC), as part of installing the MCR
Since installing the MCR requires write access to the system registry, ensure you have administrator privileges to run the MCR Installer.
The version of the MCR that runs your application on the target computer must be compatible with the version of MATLAB Compiler that built the component.
Avoid installing the MCR in MATLAB installation directories.
Include the MCR in your deployment by using the Deployment Tool.
On the Package tab of the deploytool interface, click Add MCR.
Note For more information about additional options for including the MCR Installer (embedding it in your package or locating the installer on a network share), see Packaging (Optional) in the MATLAB Compiler User's Guide or in your respective Builder User's Guide. |
When you test with the MCR, keep in mind that the MCR is an instance of MATLAB. Given this, it is not possible to load the MCR into MATLAB.
For example, if you build a generic COM component with the Deployment Tool from MATLAB Builder™ NE, you generate a DLL.
If you then try to test the component with an application such as actxserver, which loads its process into MATLAB, you are effectively loading the MCR into MATLAB, producing an error such as this:
mwsamp.mymagic(3,[],[]) ??? Invoke Error, Dispatch Exception: Source: tmw1.Class1.1_0 Description: MCR instance is not available
Therefore, understand the behaviors of third-party processes before attempting to test them with the MCR.
If you are uncertain about the behavior of these processes, contact your developer or systems administrator.
To install the MCR, perform the following tasks on the target machines:
If you added the MCR during packaging, open the package to locate the installer. Otherwise, run the command mcrinstaller to display the locations where you can download the installer.
If you are running on a platform other than Windows, set the system paths on the target machine. Setting the paths enables your application to find the MCR.
Windows paths are set automatically. On Linux and Mac, you can use the run script to set paths. See Using MATLAB Compiler on Mac or Linux for detailed information on performing all deployment tasks specifically with UNIX variants such as Linux and Mac.
Build and test the standalone application or shared library as you would any application in your environment. After you create and distribute the initial application, you continue to enhance it.
![]() | Integrating Your Shared Library With a C/C++ Application | For More Information | ![]() |

Learn how to build standalone executables and C/C++ shared libraries from MATLAB code.
| © 1984-2012- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |