Contenuto principale

Limitations for MATLAB Compiler

This topic presents limitations to consider when working with MATLAB® Compiler™ and MATLAB Runtime, including packaging limitations and other restrictions.

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

Packaging MATLAB and Toolboxes

MATLAB Compiler supports nearly the full MATLAB language and toolboxes based on MATLAB except:

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

  • Functionality that cannot be called directly from the command line

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

Compiled applications can run only on operating systems that run MATLAB. Also, because MATLAB Runtime 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, see MATLAB System Requirements.

For guidelines on multiplatform deployment, see Ensure Multiplatform Portability for Compiled Applications (MATLAB Compiler SDK).

MATLAB Compiler Generated Components

Components generated by MATLAB Compiler SDK™ or MATLAB Compiler are intended for deployment with MATLAB Runtime and cannot be used in MATLAB directly. You can test generated standalone applications in MATLAB using the system command or bang operator. For more information on testing applications in MATLAB, see Set MATLAB Library Paths for Testing Deployed Applications.

Older Neural Networks Not Deployable with MATLAB Compiler

Loading a neural network created using an older version of Deep Learning Toolbox™ versions requires some initialization routines that are not deployable with MATLAB Compiler. Therefore, you need to update the network first before deploying it.

For example, deploying a network created using 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 Parallel Pools

Deployed applications that use a shared MATLAB Runtime instance or singleton runtime cannot use more than one parallel pool. To use multiple parallel pools, refactor your code to create multiple MATLAB Runtime processes.

Parallel Computing Toolbox™ functionality is not supported in MATLAB Compiler SDK C++ shared libraries using the MATLAB Data API interface running in MATLABApplicationMode::OUT_OF_PROCESS mode.

Restrictions on Calling PRINTDLG with Multiple Arguments in Packaged Mode

When code runs in deployed mode, you can include only one argument in a call to the MATLAB printdlg function (for example, printdlg(gcf)).

If you make a call to printdlg with multiple arguments in MATLAB, you do not receive an error. However, if you deploy a compiled application containing the multiple-argument call, the action fails, and the software displays 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 the which function, as in the example below, does not cause the current folder to be searched in deployed applications. In addition, using this function might 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 a specialized function for your particular file type. load explicitly checks for the file in the current folder.

    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 the file using one of the following options: in the Files required for your application to run area of the Compiler app, the AdditionalFiles option of a compiler.build function, or the -a flag of 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.

Suppress 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 Library Paths for Deployment.

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

If your application includes graphics and you compile it using the -nojvm option, you get a run-time error.

No MATLAB File Help for Packaged Functions

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

help filename

Note

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

Using C++ SetData to Dynamically Resize mwArray

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

For instance, if you are working with the following array, you cannot use SetData to increase the size of the array to a length of five elements.

[1 2 3 4]

Accepted File Types for Packaging

The table below lists the valid and invalid file types for packaging using deployment apps.

Target ApplicationValid File TypesInvalid File Types

Standalone applications

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.

C/C++ shared libraries, .NET assemblies, Java classes, Python® packages, and COM components

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 archives

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.

See Also

Topics