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.
Did you compile with the verbose flag?
Compilation can fail in MATLAB because of errors encountered
by the system compiler when the generated wrapper code is compiled
into an executable. Additional errors and warnings are printed when
you use the verbose flag as such:
In this example,
-m
tells
MATLAB Compiler™ to
create a standalone application and
-v
tells
MATLAB Compiler and
other processors to display messages about the process.
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.
Did the MATLAB code compile successfully before this failure?
The three most common reasons for MATLAB code to stop compiling
are:
A change in the selection of the system compiler
— It is possible to inadvertently change the system compiler
for versions of MATLAB that store preferences in a common folder.
For example, MATLAB 7.0.1 (R14SP1) and MATLAB 7.0.4 (R14SP2)
store their preferences in the same folder. Changing the system compiler
in R14SP1 will also change the system compiler in R14SP2.
An upgrade to MATLAB that didn't include an upgrade
to MATLAB Compiler — The versions of MATLAB Compiler and MATLAB must
be the same in order to work together. It is possible to see conflicts
in installations where the MATLAB installation is local and the MATLAB Compiler installation
is on a network or vice versa.
Are you receiving errors when trying to compile a shared library?
Errors at compile time can indicate issues with either mcc
or mbuild
.
For troubleshooting mcc
issues, see the previous
section on compile time issues. It is recommended that your driver
application be compiled and linked using mbuild
. mbuild
can
be executed with the -v
switch to provide additional
information on the compilation process. If you receive errors at this
stage, ensure that you are using the correct header files and/or libraries
produced by mcc
, in your C or C++ driver. For example:
mcc -B csharedlib:hellolib hello.m
produces
hellolib.h
,
which is required to be included in your C/C++ driver, and
hellolib.lib
or
hellolib.so
,
which is required on the
mbuild
command line.
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, remember to include the
following statement in your MAT file:
%#function class_constructor
Using the %#function
pragma
in this manner 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 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 vendor folder. Do not reference
libraries as libmx
or libut
.
In addition, verify that your library path references the version
of MATLAB that your shared library was built with.
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.