| MATLAB® Compiler™ | ![]() |
MATLAB Compiler supports the full MATLAB language and almost all toolboxes based on MATLAB. However, some limited MATLAB and toolbox functionality is not licensed for compilation.
Most of the prebuilt graphical user interfaces included in MATLAB and its companion toolboxes will not compile.
Functionality that cannot be called directly from the command line will not compile.
Some toolboxes, such as Symbolic Math Toolbox™, will not compile.
Compiled applications can only run on operating systems that run MATLAB. Also, since the MCR is approximately the same size as MATLAB, applications built with MATLAB Compiler need specific storage memory and RAM to operate. For the most up-to-date information about system requirements, go to the MathWorks Web site.
To see a full list of MATLAB Compiler limitations, visit http://www.mathworks.com/products/compiler/compiler_support.html.
Note See Unsupported Functions for a complete list of functions that cannot be compiled. |
When MATLAB Compiler creates a standalone application, it compiles the M-file(s) you specify on the command line and, in addition, it compiles any other M-files that your M-file(s) calls. MATLAB Compiler uses a dependency analysis, which determines all the functions on which the supplied M-files, MEX-files, and P-files depend. The dependency analysis may not locate a function if the only place the function is called in your M-file is a call to the function either
In a callback string
In a string passed as an argument to the feval function or an ODE solver
MATLAB Compiler does not look in these text strings for the names of functions to compile.
Your application runs, but an interactive user interface element, such as a push button, does not work. The compiled application issues this error message:
An error occurred in the callback: change_colormap
The error message caught was : Reference to unknown function
change_colormap from FEVAL in stand-alone mode. There are several ways to eliminate this error:
Using the %#function pragma and specifying callbacks as strings
Specifying callbacks with function handles
Using the -a option
Specifying Callbacks as Strings. Create a list of all the functions that are specified only in callback strings and pass these functions using separate %#function pragma statements. This overrides the product's dependency analysis and instructs it to explicitly include the functions listed in the %#function pragmas.
For example, the call to the change_colormap function in the sample application, my_test, illustrates this problem. To make sure MATLAB Compiler processes the change_colormap M-file, list the function name in the %#function pragma.
function my_test()
% Graphics library callback test application
%#function change_colormap
peaks;
p_btn = uicontrol(gcf,...
'Style', 'pushbutton',...
'Position',[10 10 133 25 ],...
'String', 'Make Black & White',...
'CallBack','change_colormap');
Specifying Callbacks with Function Handles. To specify the callbacks with function handles, use the same code as in the example above and replace the last line with
'CallBack',@change_colormap);
For more information on specifying the value of a callback, see "Specifying the Value of Callback Function Properties" in the MATLAB Programming Fundamentals documentation.
Using the -a Option. Instead of using the %#function pragma, you can specify the name of the missing M-file on the MATLAB Compiler command line using the -a option.
To find functions in your application that may need to be listed in a %#function pragma, search your M-file source code for text strings specified as callback strings or as arguments to the feval, fminbnd, fminsearch, funm, and fzero functions or any ODE solvers.
To find text strings used as callback strings, search for the characters "Callback" or "fcn" in your M-file. This will find all the Callback properties defined by Handle Graphics® objects, such as uicontrol and uimenu. In addition, this will find the properties of figures and axes that end in Fcn, such as CloseRequestFcn, that also support callbacks.
Several warnings may appear when you run a standalone application on the UNIX system. This section describes how to suppress these warnings.
To suppress the app-defaults warnings, set XAPPLRESDIR to point to <mcr_root>/<ver>/X11/app-defaults.
To suppress the libjvm.so warning, make sure you set the dynamic library path properly for your platform. See Directories Required for Run-Time Deployment.
You can also use the MATLAB Compiler option -R -nojvm to set your application's nojvm run-time option, if the application is capable of running without Java.
If your program uses graphics and you compile with the -nojvm option, you will get a run-time error.
If you receive the error
Can't create the output file filename
there are several possible causes to consider:
Lack of write permission for the directory where MATLAB Compiler is attempting to write the file (most likely the current working directory).
Lack of free disk space in the directory where MATLAB Compiler is attempting to write the file (most likely the current working directory).
If you are creating a standalone application and have been testing it, it is possible that a process is running and is blocking MATLAB Compiler from overwriting it with a new version.
If you create an M-file with self-documenting online help by entering text on one or more contiguous comment lines beginning with the second line of the file and then compile it, the results of the command
help filename
will be unintelligible.
Note Due to performance reasons, M-file comments are stripped out before MCR encryption. |
The feature that allows you to install multiple versions of the MCR on the same machine is currently not supported on Mac OS X. When you receive a new version of MATLAB , you must recompile and redeploy all of your applications and components. Also, when you install a new MCR onto a target machine, you must delete the old version of the MCR and install the new one. You can only have one version of the MCR on the target machine.
Loading networks saved from older Neural Network Toolbox™ versions requires some initialization routines that are not deployable. Therefore, these networks cannot be deployed without first being updated.
For example, deploying with Neural Network Toolbox Version 5.0.1 (2006b) and MATLAB Compiler Version 4.5 (R2006b) yields the following errors at run time:
??? Error using ==> network.subsasgn
"layers{1}.initFcn" cannot be set to non-existing
function "initwb".
Error in ==> updatenet at 40
Error in ==> network.loadobj at 10
??? Undefined function or method 'sim' for input
arguments of type 'struct'.
Error in ==> mynetworkapp at 30In compiled mode, only one argument can be present in a call to the MATLAB printdlg function (for example, printdlg(gcf)).
You will not receive an error when making at call to printdlg with multiple arguments. However, when an application containing the multiple-argument call is compiled, the compile will fail with the following error message:
Error using = => printdlg at 11 PRINTDLG requires exactly one argument
Using which, as in this example:
function pathtest
which myFile.mat
open('myFile.mat') does not cause the current working directory to be searched in deployed applications. In addition, it may cause unpredictable behavior of the open function.
Use one of the following solutions as alternatives to using which:
Use the pwd function to explicitly point to the file in the current directory, as follows:
open([pwd 'myFile.mat'])
Rather than using the general open function, use load or other specialized functions for your particular file type, as load explicitly checks for the file in the current directory. For example:
load myFile.mat
Use addpath(pwd) to add the current directory to the deployed application's file search path. This directory should not include any unencrypted M-files, as these cannot be executed by the compiled application.
Include your file using the Other Files area of your project using deploytool (and the -a flag using mcc).
![]() | Limitations and Restrictions | Reference Information | ![]() |
| © 1984-2009- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |