Set MATLAB Runtime Path for Deployment
Applications generated with MATLAB®
Compiler™ or MATLAB
Compiler SDK™ use the system library path to locate the MATLAB Runtime libraries. After you install MATLAB Runtime, add the run-time directories to the system library path according to the
instructions for your operating system and shell environment. Alternatively, pass the location
of MATLAB Runtime as an input to the associated shell script
(run_
). application
.sh
Note
Save the value of your current library path as a backup before modifying it.
Your library path may contain multiple versions of MATLAB Runtime. Applications launched without using the shell script use the first version listed in the path.
If you are using a network install of MATLAB Runtime, see Run Applications Using a Network Installation of MATLAB Runtime.
Environment Variables and MATLAB Runtime Directories
Operating System | Environment Variable | Directories |
---|---|---|
Windows® | PATH |
|
Linux® | LD_LIBRARY_PATH |
|
macOS | DYLD_LIBRARY_PATH |
|
Windows
The MATLAB Runtime installer for Windows automatically sets the library path during installation. If you do not use
the installer, complete the following steps to set the PATH
environment
variable permanently.
Run
C:\Windows\System32\SystemPropertiesAdvanced.exe
and click the Environment Variables... button.Select the system variable
Path
and click Edit....Note
If you do not have administrator rights on the machine, select the user variable
Path
instead of the system variable.Click New and add the directory
. For example, if you are using MATLAB Runtime R2022a located in the default installation directory on 64-bit Windows, add<MATLAB_RUNTIME_INSTALL_DIR>
\runtime\<arch>
C:\Program Files\MATLAB\MATLAB Runtime\v912\runtime\win64
.Click OK to apply the change.
Linux
For information on setting environment variables in shells other than Bash, see your shell documentation.
Bash Shell
Display the current value of
LD_LIBRARY_PATH
in the terminal.echo $LD_LIBRARY_PATH
Append the MATLAB Runtime directories to the
LD_LIBRARY_PATH
variable for the current session.export LD_LIBRARY_PATH="${LD_LIBRARY_PATH:+${LD_LIBRARY_PATH}:}\
<MATLAB_RUNTIME_INSTALL_DIR>
/runtime/glnxa64:\<MATLAB_RUNTIME_INSTALL_DIR>
/bin/glnxa64:\<MATLAB_RUNTIME_INSTALL_DIR>
/sys/os/glnxa64:\<MATLAB_RUNTIME_INSTALL_DIR>
/extern/bin/glnxa64"Note
If you require Mesa Software OpenGL® rendering to resolve low level graphics issues, add the directory
to the path. For details, see Resolving Low-Level Graphics Issues.<MATLAB_RUNTIME_INSTALL_DIR>
/sys/opengl/lib/glnxa64For example, if you are using MATLAB Runtime R2022a located in the default installation directory, use the following command:
export LD_LIBRARY_PATH="${LD_LIBRARY_PATH:+${LD_LIBRARY_PATH}:}\ /usr/local/MATLAB/MATLAB_Runtime/v912/runtime/glnxa64:\ /usr/local/MATLAB/MATLAB_Runtime/v912/bin/glnxa64:\ /usr/local/MATLAB/MATLAB_Runtime/v912/sys/os/glnxa64:\ /usr/local/MATLAB/MATLAB_Runtime/v912/extern/bin/glnxa64"
Display the new value of
LD_LIBRARY_PATH
to ensure the path is correct.echo $LD_LIBRARY_PATH
Type
ldd --version
to check your version of GNU® C library (glibc
). If the version displayed is 2.17 or lower, add
to the<MATLAB_RUNTIME_INSTALL_DIR>
/bin/glnxa64/glibc-2.17_shim.soLD_PRELOAD
environment variable using the following command:export LD_PRELOAD="${LD_PRELOAD:+${LD_PRELOAD}:}\
<MATLAB_RUNTIME_INSTALL_DIR>
/bin/glnxa64/glibc-2.17_shim.so"
macOS
Display the current value of
DYLD_LIBRARY_PATH
in the terminal.echo $DYLD_LIBRARY_PATH
Append the MATLAB Runtime directories to the
DYLD_LIBRARY_PATH
variable for the current session.export DYLD_LIBRARY_PATH="${DYLD_LIBRARY_PATH:+${DYLD_LIBRARY_PATH}:}\
<MATLAB_RUNTIME_INSTALL_DIR>
/runtime/maci64:\<MATLAB_RUNTIME_INSTALL_DIR>
/bin/maci64:\<MATLAB_RUNTIME_INSTALL_DIR>
/sys/os/maci64:\<MATLAB_RUNTIME_INSTALL_DIR>
/extern/bin/maci64"For example, if you are using MATLAB Runtime R2022a located in the default installation directory, use the following command:
export DYLD_LIBRARY_PATH="${DYLD_LIBRARY_PATH:+${DYLD_LIBRARY_PATH}:}\ /Applications/MATLAB/MATLAB_Runtime/v912/runtime/maci64:\ /Applications/MATLAB/MATLAB_Runtime/v912/bin/maci64:\ /Applications/MATLAB/MATLAB_Runtime/v912/sys/os/maci64:\ /Applications/MATLAB/MATLAB_Runtime/v912/extern/bin/maci64"
Display the value of
DYLD_LIBRARY_PATH
to ensure the path is correct.echo $DYLD_LIBRARY_PATH
Set Path Permanently on UNIX
Caution
The MATLAB Runtime libraries may conflict with other applications that use the library path. In this case, set the path only for the current session, or run MATLAB Compiler applications using the generated shell script.
To set an environment variable at login on Linux or macOS, append the export
command to the shell configuration file
~/.bash_profile
in a Bash shell, or ~/.zprofile
in
a Zsh shell.
To determine your current shell environment, type echo
$SHELL
.