Testing Failures
After you have successfully compiled your application, the next
step is to test it on a development machine and deploy it on a target
machine. Typically the target machine does not have a MATLAB® installation
and requires that the MATLAB Runtime be installed. A distribution
includes all of the files that are required by your application to
run, which include the executable, deployable archive and the MATLAB Runtime.
Test the application on the development machine by running the
application against the MATLAB Runtime shipped with MATLAB Compiler SDK™.
This will verify that library dependencies are correct, that the deployable
archive can be extracted and that all MATLAB code, MEX—files
and support files required by the application have been included in
the archive. If you encounter errors testing your application, the
questions in the column to the right may help you isolate the problem.
Are you able to execute the application from MATLAB?
On the development machine, you can test your application's
execution by issuing !
application-name
at
the MATLAB prompt. If your application executes within MATLAB but
not from outside, this can indicate an issue with the one of the system
variables:
PATH
LD_LIBRARY_PATH
DYLD_LIBRARY_PATH
Does the application begin execution and result in MATLAB or
other errors?
Ensure that you included all necessary files when compiling
your application (see the readme.txt
file generated
with your compilation for more details).
Functions that are called from your main MATLAB file are
automatically included by MATLAB Compiler SDK as are functions
included using the %#function
pragma. However,
functions that are not explicitly called, for example through EVAL,
need to be included at compilation using the -a
switch
of the mcc
command. Also, any support files like .mat
, .txt
,
or .html
files need to be added to the archive
with the -a
switch. There is a limitation on the
functionality of MATLAB and associated toolboxes that can be
compiled. Check the documentation to see that the functions used in
your application's MATLAB files are valid. Check the file mccExcludedFiles.log
on
the development machine. This file lists all functions called from
your application that cannot be compiled.
Do you have multiple MATLAB versions installed?
Executables generated using MATLAB Compiler SDK components
are designed to run in an environment where multiple versions of MATLAB are
installed. Some older versions of MATLAB may not be fully compatible
with this architecture.
On Windows, ensure that the matlabroot
\runtime\win32|win64
of
the version of MATLAB in which you are compiling appears ahead
of matlabroot
\runtime\win32|win64
of
other versions of MATLAB installed on the PATH
environment
variable on your machine.
Similarly, on UNIX®, ensure that the dynamic library paths
(LD_LIBRARY_PATH
on Linux®) match. Do this
by comparing the outputs of !printenv
at the MATLAB prompt
and printenv
at the shell prompt. Using this path
allows you to use mcc
from the operating system
command line.
Do you receive an error message about a missing DLL?
Error messages indicating missing DLLs such as mclmcrrt7x.dll
or mclmcrrt7x.so
are
generally caused by incorrect installation of the MATLAB Runtime.
It is also possible that the MATLAB Runtime is installed correctly,
but that the PATH
,LD_LIBRARY_PATH
, or DYLD_LIBRARY_PATH
variables
are set incorrectly. For information on installing the MATLAB Runtime on
a deployment machine, refer to Install the MATLAB Runtime.
Caution
Do not solve these problems by moving libraries or other files
within the MATLAB Runtime folder structure. The MATLAB Runtime system
is designed to accommodate different MATLAB Runtime versions operating
on the same machine. The folder structure is an important part of
this feature. |
Are you receiving errors when trying to run the shared library
application?
Calling MATLAB Compiler SDK generated shared libraries requires
correct initialization and termination in addition to library calls
themselves. For information on calling shared libraries, see Call MATLAB Compiler SDK API Functions from C/C++.
Some key points to consider to avoid errors at run time:
Ensure that the calls to mclinitializeApplication
and libname
Initialize
are
successful. The first function enables construction of MATLAB Runtime instances.
The second creates the MATLAB Runtime instance required by the
library named libname
.
If these calls are not successful, your application will not execute.
Do not use any mw-
or mx-
functions
before calling mclinitializeApplication
. This includes
static and global variables that are initialized at program start.
Referencing mw-
or mx-
functions
before initialization results in undefined behavior.
Do not re-initialize (call mclinitializeApplication
)
after terminating it with mclTerminateApplication
.
The mclinitializeApplication
andlibname
Initialize
functions
should be called only once.
Ensure that you do not have any library calls after mclTerminateApplication
.
Ensure that you are using the correct syntax to call
the library and its functions.
Does your system's graphics card support the graphics
application?
In situations where the existing hardware graphics card does
not support the graphics application, you should use software OpenGL®. OpenGL libraries
are visible for an application by appending matlab/sys/opengl/lib/arch
to
the LD_LIBRARY_PATH
. For example:
setenv LD_LIBRARY_PATH $LD_LIBRARY_PATH:matlab/sys/opengl/lib/arch
Is OpenGL properly installed on your system?
When searching for OpenGL libraries, the MATLAB Runtime first
looks on the system library path. If OpenGL is not found there,
it will use the LD_LIBRARY_PATH
environment variable
to locate the libraries. If you are getting failures due to the OpenGL libraries
not being found, you can append the location of the OpenGL libraries
to the LD_LIBRARY_PATH
environment variable. For example:
setenv LD_LIBRARY_PATH $LD_LIBRARY_PATH:matlab/sys/opengl/lib/glnxa64