Compilation Failures
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.
Is your installed compiler supported by MATLAB
Compiler SDK?
Are you compiling within or outside of MATLAB?
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:
lists the environment on Windows
® platforms.
lists the
environment on UNIX
® platforms. Using this path allows you to use
mcc
from the operating system command line.
Have you tried to compile any of the C/C++ examples in MATLAB
Compiler SDK help?
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.
Is your MATLAB object failing to load?
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.
If you are compiling a driver application, are you using mbuild?
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.
Are you trying to compile your driver application using Microsoft
Visual Studio or another IDE?
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
.
Are you importing the correct versions of import libraries?
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.
Are you able to compile the matrixdriver example?
Try following the example Create a 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.
Do you get the MATLAB:I18n:InconsistentLocale
Warning?
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.