Contenido principal

Compilation Failures

R2026b

You typically compile your MATLAB® code on a development machine, test the resulting executable on that machine, and deploy the executable and MATLAB Runtime to a test or customer machine without MATLAB. The compilation process performs dependency analysis on your MATLAB code, creates an encrypted archive of your code and required toolbox code, generates wrapper code, and compiles the wrapper code into an executable. If your application fails to build an executable, the following questions may help you isolate the problem.

See the current list of supported compilers at http://www.mathworks.com/support/compilers/current_release/.

mcc can be invoked from the operating system command line or from the MATLAB prompt. When you run mcc inside the MATLAB environment, MATLAB will modify environment variables in its environment as necessary so mcc will run. Issues with PATH, LD_LIBRARY_PATH, or other environment variables seen at the operating system command line are often not seen at the MATLAB prompt. The environment that MATLAB uses for mcc can be listed at the MATLAB prompt. For example:

>>!set
lists the environment on Windows® platforms.
>>!printenv
lists the environment on UNIX® platforms. Using this path allows you to use mcc from the operating system command line.

The source code for all C/C++ examples is provided with MATLAB Compiler SDK™ and is located in matlabroot\extern\examples\compilersdk, where matlabroot is the root folder of your MATLAB installation.

If your MATLAB object fails to load, it is typically a result of the MATLAB Runtime not finding required class definitions.

When working with MATLAB objects that are loaded from a MAT file, remember to include the following statement in your MATLAB function:

%#function class_constructor 

Using the %#function pragma forces dependency analyzer to load needed class definitions, enabling the MATLAB Runtime to successfully load the object.

MathWorks® recommends and supports using mbuild to compile your driver application. mbuild is designed and tested to correctly build driver applications. It will ensure that all MATLAB header files are found by the C/C++ compiler, and that all necessary libraries are specified and found by the linker.

If you are using an IDE, in addition to linking to the generated export library, you need to include an additional dependency to mclmcrrt.lib. This library is provided for all supported Microsoft® compilers in matlabroot\extern\lib\arch\microsoft.

If you have multiple versions of MATLAB installed on your machine, it is possible that an older or incompatible version of the library is referenced. Ensure that the only MATLAB library that you are linking to is mclmcrrt.lib and that it is referenced from the appropriate folder.

Try following the example Create C Shared Library with MATLAB Code. Typically, if you cannot compile the examples in the documentation, it indicates an issue with the installation of MATLAB or your system compiler.

The warning message

MATLAB:I18n:InconsistentLocale - The system locale setting, 
system_locale_name, is different from the user locale 
setting, user_locale_name
indicates a mismatch between locale setting on Microsoft Windows systems. This may affect your ability to display certain characters. For information about changing the locale settings, see your operating system Help.