MATLAB: What environment variable is used to specify the search path for loading shared libraries into MATLAB on the Mac OS X

envenvironmentexecutableld_library_pathmacmacintoshMATLAB Compilerososxpathsetenvstand-alonestandalonevariablex

I am trying to follow your instructions in the MATLAB Compiler documentation and in the online help to distribute a stand-alone application on the Macintosh. After moving the executable onto my target computer, unpacking the libraries, and then adding the bin/<ARCH> directory to the LD_LIBRARY_PATH environment variable, I am still unable to run the executable.
I receive the error during run-time:
dyld: ./grasp can't open library:
/devel/R12/build/extern/lib/mac/libmwsgl.dylib (No such file or
directory, errno = 2)
Trace/BPT trap

Best Answer

This bug has been fixed for Release 14 (R14). For previous releases, please read below for any possible workarounds:
The LD_LIBRARY_PATH environment variable is not valid for use on the Mac OS X. The correct equivalent variable is DYLD_LIBRARY_PATH and it should be set to the directory location of the MATLAB Math and Graphics libraries. You set this environment variable by doing the following shell command prior to running your executable:
Determine what shell you are using:
echo $SHELL
Look for bash, or tcsh.
If bash:
export DYLD_LIBRARY_PATH=$MGLINSTALLER/bin/mac/:$DYLD_LIBRARY_PATH
If tcsh:
setenv DYLD_LIBRARY_PATH $MGLINSTALLER/bin/mac/:$DYLD_LIBRARY_PATH
where $MGLINSTALLER represents the MGLINSTALLER installation directory.