MATLAB: How to configure the LD_LIBRARY_PATH on Linux and DYLD_LIBRARY_PATH on MAC OS X to point to MCR

MATLAB CompilerMATLAB Compiler SDK

How do I configure the LD_LIBRARY_PATH on Linux and DYLD_LIBRARY_PATH on MAC OS X to point to MCR?

Best Answer

To set the LD_LIBRARY_PATH on Linux follow the steps below:
1. Determine Linux shell being used. Use the following command on the Linux terminal:
echo $SHELL
For a TCSH shell this will return "/bin/tcsh"
For a BASH shell this will return "/bin/bash"
2. Check if you have a .tcshrc or .bashrc file ("the startup file") on your system. These files are run whenever a new terminal is opened.
ls -all
3. If the startup file is not present, you can create one for TCSH/BASH respectively:
touch .tcshrc
touch .bashrc
4. Check if LD_LIBRARY_PATH has been set already:
echo $LD_LIBRARY_PATH
This will either return the value for LD_LIBRARY_PATH or the following message:
LD_LIBRARY_PATH: Undefined variable
5. Open the file for editing in vi for TCSH/BASH respectively:
vi .tcshrc
vi .bashrc
6. Append the paths from the Configuration Notes dialog box ("<mypath>") obtained during MCR installation.
If LD_LIBRARY_PATH was not already set (refer to Step 4), append the variable using the first line. Otherwise, use the second.
For BASH:
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:<mypath>
or
export LD_LIBRARY_PATH=<mypath>
For TCSH:
setenv LD_LIBRARY_PATH {$LD_LIBRARY_PATH}:<mypath>
or
setenv LD_LIBRARY_PATH <mypath>
7. Save and exit vi using Shift + :wq
8. Confirm the LD_LIBRARY_PATH has been set correctly. Open a new terminal and execute:
echo $LD_LIBRARY_PATH
This should now reflect the paths to the MCR that you just set.
NOTE:
To set DYLD_LIBRARY_PATH on MAC OS X 10.11 and newer, you must use the following syntax when running an application ("run.app"):
DYLD_LIBRARY_PATH="/my/path/to/mcr" ./run.app
This is because dynamic library environment variables are no longer copied to child processes, due to System Integrity Protection.