MATLAB Answers

How can I distribute an application that is developed using MATLAB?

237 views (last 30 days)
I would like to distribute the MATLAB code that I have developed. What are some ways to package and distribute this code as an application to users who do not have MATLAB?

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 22 Feb 2012
Section 1: Overview of Deployment Options
MATLAB® deployment products convert MATLAB programs into applications and components that you can distribute to end users who do not have MATLAB installed. Deployed applications run as MATLAB code against a set of supporting MATLAB libraries called the MATLAB Component Runtime (MCR). The deployment products generate wrapper code to allow your MATLAB application to run as a stand-alone executable or interact with other technologies, but your application remains in MATLAB code. Thus, the execution time of deployed code will be almost identical to the execution time in MATLAB.
You can deploy MATLAB applications as:
Stand-alone executables using MATLAB Compiler™
C or C++ libraries using MATLAB Compiler™
Java classes using MATLAB Builder™ JA
Microsoft .NET or COM components using MATLAB Builder™ NE
Microsoft Excel add-ins using MATLAB Builder™ EX
All deployed components and applications can be distributed free of charge. The deployment products support the MATLAB language, most MATLAB toolboxes, and user-developed GUIs.
Section 2: How Does the MATLAB® Compiler™ Work
You can create deployable applications and components either by using the command line MCC command or by using the Deployment Tool Graphical User Interface.
An application or component generated by MATLAB Compiler™ has two parts: a platform-specific binary file and an archive file containing MATLAB functions and data. For an application, the binary file consists of a main function, and for a library the binary file exports multiple functions that can be called by users of the library. The wrapper file provides an interface to the compiled MATLAB code. Wrapper files differ depending on the execution environment. The archive file, called a Component Technology File. which is named with a .ctf suffix, contains the MATLAB functions and data that define the application or library.
Any application or component created from the same version of MATLAB can then run against the same MCR – it is not necessary to distribute a new MCR with each update of your application or component.
Section 3: Deployment Tool Workflow
Open the Deployment Tool by issuing the following command at the MATLAB prompt:
Use the Deployment Tool as follows to create and package either a standalone application or a shared library:
(a) Create a new project.
(b) Add files that you want to compile.
(c) Set properties for building and packaging.
(d) Save the project.
(e) Build the component.
(f) Test, edit and rebuild as necessary.
(g) Package the component for distribution to programmers or end users.
For more information on the mcc command, consult the MATLAB documentation.
Section 4: Deploying with the Compiler
You need three main components when distributing your application:
(a) The component wrapper or application wrapper you have created (for example, .exe or .dll)
(b) The archive file containing all of the MATLAB code used in your component or application – this is called the CTF (Component Technology File) and has the extension .ctf
(c) The MCR
You may use the package option in the Deployment Tool to package the wrapper, archive, and, optionally, the MCR into a single zip file for distribution.
Section 5: What If All Else Fails?
If you have tried all of the above steps and are still having trouble distributing your application, use this form to contact technical support. Be sure to include the following:
(a) The version of MATLAB you are using
(b) The system path of the target machine
(c) The name of the directory where the run-time libraries are installed
(d) The exact error message


Show 3 older comments
Walter Roberson
Walter Roberson on 15 Oct 2015
No, applications must be created on the operating system class they are to run on. The exception to this is that you can use a 64 bit version of MS Windows to create a .exe to run on a 32 bit version of MS Windows.
I have a doubt with regard to matlab compiler. I have compiled a matlab function to java classes in windows machine. I created an eclipse java project including all the generated class files and the .ctf (archive file) file. I created a jar file out of this java project. It worked perfectly in windows, when I referenced the external jar javabuilder.jar (from MCR). Is it possible to execute this jar file without problems in linux machine? My doubt comes from the fact that binary files (like .exe and .dll) generated by matlab compiler are platform specific. Since I am not using any binary files, but only .ctf file and .class files, I assume that the jar file would fine in Linux. Is my assumption right?
Thank you very much.
Walter Roberson
Walter Roberson on 29 Dec 2016
No, the java that is created uses JNI to call platform-specific libraries.

Sign in to comment.

More Answers (2)

Graham Horsley
Graham Horsley on 9 Mar 2015
Hi, is it permissible for us to distribute the relevant MCR installer alongside our application (as opposed to packaging it within the application's installer)?

  1 Comment

Madhura Suresh
Madhura Suresh on 13 Mar 2015
Yes. You can do that as long as you have a valid license for the MATLAB Compiler.

Sign in to comment.

MOHIT KUMAR on 17 Nov 2017
error while deploying what sholud i do ant:
<mkdir dir="C:\Users\mohit\Documents\MATLAB\project\for_redistribution" />
<mkdir dir="C:\Users\mohit\Documents\MATLAB\project\for_testing" />
mcc -C -o project -W WinMain:project -T link:exe -d C:\Users\mohit\Documents\MATLAB\project\for_testing -v C:\Users\mohit\Documents\MATLAB\project.m
Test checkout of feature 'Compiler' failed.
mcc failed.


Sign in to comment.


No tags entered yet.




Translated by