MATLAB: Do I receive a fatal error when I run the MATLAB Compiler-generated executable from the UNIX prompt

cannoterrorexecutablefatalld_library_pathlibmwsgl.solibrarymapMATLAB Compilerrununix

Why do I receive a fatal error when I try to run my MATLAB Compiler-generated executable from the UNIX prompt?
1. I used MBUILD to create a standalone executable from ex1.c found in the $MATLAB/extern/examples/cmath directory (where $MATLAB is the root MATLAB directory). I created the standalone file "ex1".
2. I exited MATLAB and tried to run the "ex1" file in the UNIX environment, but I got the following error message:
UNIX > ex1
26883:ex1: /sbin/loader: Fatal Error: cannot map libmmfile.so

Best Answer

This error message occurs because your executable cannot find one or more of the files it needs to link with in order to run.
The files it needs are located in the following directories:
$MATLAB/extern/lib/$ARCH
$MATLAB/bin/$ARCH
$MATLAB/sys/os/$ARCH
Note:
$MATLAB refers to the root directory where you installed MATLAB.
$ARCH refers to the architecture of your specific UNIX machine (e.g., glnx86).
These folders should be on your system PATH and LD_LIBRARY_PATH variables.
To add them to your PATH and LD_LIBRARY_PATH, type the following commands at your UNIX shell prompt:
setenv PATH $MATLAB/extern/lib/$ARCH:$MATLAB/bin/$ARCH:$PATH
setenv LD_LIBRARY_PATH $MATLAB/extern/lib/$ARCH:$MATLAB/bin/$ARCH:$LD_LIBRARY_PATH
Note:
- $PATH and $LD_LIBRARY_PATH should be used just as they appear in the above commands.