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. The MATLAB Runtime installer for Windows® automatically sets the library path during installation, but on Linux® or macOS you must add the libraries manually. After you install MATLAB Runtime, add the run-time folders to the system library path according to the instructions for your operating system and shell environment.
Alternatively, you can pass the location of MATLAB Runtime as an input to the associated shell script
(run_
) on Linux or macOS to launch an application. application
.sh
Note
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.
Save the value of your current library path as a backup before modifying it.
If you are using a network install of MATLAB Runtime, see Deploy Applications and MATLAB Runtime on Network Drives.
Library Path Environment Variables and MATLAB Runtime Folders
Operating System | Environment Variable | Directories |
---|---|---|
Windows | PATH |
|
Linux | LD_LIBRARY_PATH |
|
macOS (Intel® processor) | DYLD_LIBRARY_PATH |
|
macOS (Apple silicon) | 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 folder
.<MATLAB_RUNTIME_INSTALL_DIR>
\runtime\<arch>
For example, if you are using MATLAB Runtime R2024b located in the default installation folder on 64-bit Windows, add
C:\Program Files\MATLAB\MATLAB Runtime\R2024b\runtime\win64
.Click OK to apply the change.
Note
If the path contains multiple versions of MATLAB Runtime, applications use the first version listed in the path.
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 folders to the
LD_LIBRARY_PATH
variable for the current session.For example, if you are using MATLAB Runtime R2024b located in the default installation folder, use the following command.
export LD_LIBRARY_PATH="${LD_LIBRARY_PATH:+${LD_LIBRARY_PATH}:}\ /usr/local/MATLAB/MATLAB_Runtime/R2024b/runtime/glnxa64:\ /usr/local/MATLAB/MATLAB_Runtime/R2024b/bin/glnxa64:\ /usr/local/MATLAB/MATLAB_Runtime/R2024b/sys/os/glnxa64:\ /usr/local/MATLAB/MATLAB_Runtime/R2024b/extern/bin/glnxa64"
Note
If you require Mesa Software OpenGL® rendering to resolve low level graphics issues, add the folder
to the path. For details, see Resolving Low-Level Graphics Issues.<MATLAB_RUNTIME_INSTALL_DIR>
/sys/opengl/lib/glnxa64Display 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}:}\ /usr/local/MATLAB/MATLAB_Runtime/R2024b/bin/glnxa64/glibc-2.17_shim.so"
To make these changes permanent, see Set Path Permanently on UNIX.
macOS
Display the current value of
DYLD_LIBRARY_PATH
in the terminal.echo $DYLD_LIBRARY_PATH
Append the MATLAB Runtime folders to the
DYLD_LIBRARY_PATH
variable for the current session.For example, if you are using MATLAB Runtime R2024b located in the default installation folder, use one of the following commands depending on your system architecture.
For Intel processor-based macOS, use the
maci64
directories.export DYLD_LIBRARY_PATH="${DYLD_LIBRARY_PATH:+${DYLD_LIBRARY_PATH}:}\ /Applications/MATLAB/MATLAB_Runtime/R2024b/runtime/maci64:\ /Applications/MATLAB/MATLAB_Runtime/R2024b/bin/maci64:\ /Applications/MATLAB/MATLAB_Runtime/R2024b/sys/os/maci64:\ /Applications/MATLAB/MATLAB_Runtime/R2024b/extern/bin/maci64"
For Apple silicon-based macOS, use the
maca64
directories.export DYLD_LIBRARY_PATH="${DYLD_LIBRARY_PATH:+${DYLD_LIBRARY_PATH}:}\ /Applications/MATLAB/MATLAB_Runtime/R2024b/runtime/maca64:\ /Applications/MATLAB/MATLAB_Runtime/R2024b/bin/maca64:\ /Applications/MATLAB/MATLAB_Runtime/R2024b/sys/os/maca64:\ /Applications/MATLAB/MATLAB_Runtime/R2024b/extern/bin/maca64"
Display the value of
DYLD_LIBRARY_PATH
to ensure the path is correct.echo $DYLD_LIBRARY_PATH
To make these changes permanent, see Set Path Permanently on UNIX.
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 SDK 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
.