Main Content

Limitations

Packaging MATLAB and Toolboxes

MATLAB® Compiler SDK™ supports the full MATLAB language and almost all toolboxes based on MATLAB except:

  • Most of the prebuilt graphical user interfaces included in MATLAB and its companion toolboxes.

  • Functionality that cannot be called directly from the command line.

Compiled applications can run only on operating systems that run MATLAB. However, components generated by the MATLAB Compiler SDK cannot be used in MATLAB. Also, since MATLAB Runtime is approximately the same size as MATLAB, applications built with MATLAB Compiler SDK need specific storage memory and RAM to operate. For the most up-to-date information about system requirements, see the MATLAB System Requirements.

Compiled applications can run only on the same platform on which they were developed, with the following exceptions:

  • Web apps, which can be deployed to MATLAB Web App Server™ running on any compatible platform.

  • C++ libraries compiled using the MATLAB Data API that do not contain platform-specific files.

  • .NET Assemblies compiled using .NET Core that do not contain platform-specific files.

  • Java® packages that do not contain platform-specific files.

  • Python® packages that do not contain platform-specific files.

Note

Simulink® Compiler™ artifacts are not cross-platform compatible and must be built on the same platform on which they are deployed.

To see the full list of MATLAB Compiler SDK limitations, visit: https://www.mathworks.com/products/compiler/compiler_support.html.

Note

For a list of functions not supported by the MATLAB Compiler SDK See Functions Not Supported for Compilation by MATLAB Compiler and MATLAB Compiler SDK.

Callback Problems Due to Missing Functions

When MATLAB Compiler SDK creates an application, it packages the MATLAB files that you specify. In addition, it includes any other MATLAB files that your packaged MATLAB files call. MATLAB Compiler SDK uses a dependency analysis function that determines all the functions on which the supplied MATLAB files, MEX-files, and P-files depend.

Note

If the MATLAB file associated with a p-file is unavailable, the dependency analysis cannot discover the p-file dependencies.

The dependency analysis cannot locate a function if the only place the function is called in your MATLAB file is a call to the function in either of the following:

  • Callback string

  • Character array passed as an argument to the feval function or an ODE solver

    Tip

    Dependent functions can also be hidden from the dependency analyzer in .mat files that are loaded by compiled applications. Use the mcc -a argument or the %#function pragma to identify .mat file classes or functions that are supported by the load command.

MATLAB Compiler SDK does not look in these text character arrays for the names of functions to package.

Symptom

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. 

Workaround

There are several ways to eliminate this error:

  • Using the %#function pragma and specifying callbacks as character arrays

  • Specifying callbacks with function handles

  • Include the MATLAB function in the Files required for your application to run area of a Compiler app, the AdditionalFiles option using a compiler.build function, or the -a flag using mcc.

Specifying Callbacks as Character Arrays.  Create a list of all the functions that are specified only in callback character arrays and pass these functions using separate %#function pragma statements. This overrides the product 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 SDK processes the change_colormap MATLAB 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 the MATLAB Programming Fundamentals documentation.

Finding Missing Functions in MATLAB File

To find functions in your application that need to be listed in a %#function pragma, search your MATLAB file source code for text specified as callback character arrays or as arguments to the feval, fminbnd, fminsearch, funm, and fzero functions or any ODE solvers.

To find text used as callback character array, search for the characters “Callback” or “fcn” in your MATLAB file. This search finds all the Callback properties defined by graphics objects, such as uicontrol and uimenu. In addition, it finds the properties of figures and axes that end in Fcn, such as CloseRequestFcn, that also support callbacks.

Suppressing Warnings on UNIX System

Several warnings might appear when you run a standalone application on UNIX® systems.

To suppress the libjvm.so warning, set the dynamic library path properly for your platform. For details, see Set MATLAB Runtime Path for Deployment.

You can also use the compiler option -R -nojvm to set your application's nojvm runtime option, if the application is capable of running without Java.

Cannot Use Graphics with -nojvm Option

If your program uses graphics and you compile with the -nojvm option, you get a runtime error.

Cannot Create Output File

If you receive this error, there are several possible causes to consider.

Can't create the output file filename

Possible causes include:

  • Lack of write permission for the folder where MATLAB Compiler SDK is attempting to write the file (most likely the current working folder).

  • Lack of free disk space in the folder where MATLAB Compiler SDK is attempting to write the file (most likely the current working folder).

  • 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 SDK from overwriting it with a new version.

No MATLAB File Help for Packaged Functions

If you create a MATLAB file with self-documenting online help and package it, the results of following command are unintelligible:

help filename

Note

For performance reasons, MATLAB file comments are stripped out before MATLAB Runtime encryption.

No MATLAB Runtime Versioning on Mac OS X

The feature that allows you to install multiple versions of MATLAB Runtime on the same machine is not supported on Mac OS X. When you receive a new version of MATLAB, you must recompile and redeploy all your applications and components. Also, when you install a new version of MATLAB Runtime on a target machine, you must delete the old version of MATLAB Runtime before installing the new one. You can have only one version of MATLAB Runtime on the target machine.

Older Neural Networks Not Deployable with MATLAB Compiler

Loading networks saved from older Deep Learning Toolbox™ versions requires some initialization routines that are not deployable. Therefore, these networks cannot be deployed without first being updated.

For example, deploying with Deep Learning 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 30

Restrictions on Calling PRINTDLG with Multiple Arguments in Packaged Mode

In compiled mode, only one argument can be present in a call to the MATLAB printdlg function (for example, printdlg(gcf)).

You cannot receive an error when making at call to printdlg with multiple arguments. However, when an application containing the multiple-argument call is packaged, the action fails with the following error message:

Error using = => printdlg at 11 
PRINTDLG requires exactly one argument 

Opening File Using which and open Does Not Search Current Working Folder

Using which, as in this example, does not cause the current working folder to be searched in deployed applications. In addition, it may cause unpredictable behavior of the open function.

function pathtest 
which myFile.mat 
open('myFile.mat') 

Use one of the following solutions as an alternative:

  • Use load or other specialized functions for your particular file type, as load explicitly checks for the file in the current folder. For example:

    load myFile.mat

  • Use the ctfroot function to explicitly point to the file location relative to the deployable archive.

    load(fullfile(ctfroot,'..','datafiles','data1.mat'));

  • Include your file in the Files required for your application to run area of the Compiler app, the AdditionalFiles option using a compiler.build function, or the -a flag using mcc. You can then locate the file using the which function.

For more information on including data files with your application, see Include and Access Files in Packaged Applications.

Restrictions on Using C++ SetData to Dynamically Resize an mwArray

You cannot use the C++ SetData method to dynamically resize mwArrays.

For instance, if you are working with the following array:

[1 2 3 4]

you cannot use SetData to increase the size of the array to a length of five elements.

Accepted File Types for Packaging

The valid and invalid file types for packaging using deployment apps are as follows.

Target ApplicationValid File TypesInvalid File Types

Standalone Application

MATLAB MEX files, MATLAB scripts, MATLAB functions, and MATLAB class files. These files must have a single entry point.

Protected function files (.p files), Java functions, COM or .NET components, and data files.

Library Compiler

MATLAB MEX files, MATLAB functions, and MATLAB class files. These files must have a single entry point.

MATLAB scripts, protected function files (.p files), Java functions, COM or .NET components, and data files.

MATLAB Production Server

MATLAB MEX files and MATLAB functions. These files must have a single entry point.

MATLAB scripts, MATLAB class files, protected function files (.p files), Java functions, COM or .NET components, and data files. MATLAB class files can be dependent files.

You can add other types of files to the packaged code archive, such as data files. For more information, see Include and Access Files in Packaged Applications.

Related Topics