Set MATLAB Runtime Library Paths for Deployment
Applications generated with MATLAB® Compiler™ or MATLAB Compiler SDK™ require access to MATLAB Runtime libraries to function properly. MATLAB Runtime provides essential components that allow these compiled applications to run without requiring a MATLAB installation. These applications locate the necessary libraries through your system's library path environment variables.
On Windows®, the installer for MATLAB Runtime automatically sets the library path during installation. On Linux® and macOS systems, manually add the appropriate library folders to your system path after installing MATLAB Runtime. Follow the instructions for your specific operating system and shell environment.
For standalone applications on Linux and macOS, MATLAB
Compiler generates a shell script named
run_application.sh. You pass the location of
MATLAB Runtime as an argument to the script, which then sets up the library paths. Use this
script as an alternative method to specify the runtime location when launching standalone
applications. For
example:
./run_application.sh <MATLAB_RUNTIME_INSTALL_DIR> [arguments]
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 (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.exeand click the Environment Variables... button.Select the system variable
Pathand click Edit....Note
If you do not have administrator rights on the machine, select the user variable
Pathinstead of the system variable.Click New and add the folder
.<MATLAB_RUNTIME_INSTALL_DIR>\runtime\<arch>For example, if you are using MATLAB Runtime R2026a located in the default installation folder on 64-bit Windows, add
C:\Program Files\MATLAB\MATLAB Runtime\R2026a\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_PATHin the terminal.echo $LD_LIBRARY_PATHAppend the MATLAB Runtime folders to the
LD_LIBRARY_PATHvariable for the current session.For example, if you are using MATLAB Runtime R2026a 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/R2026a/runtime/glnxa64:\ /usr/local/MATLAB/MATLAB_Runtime/R2026a/bin/glnxa64:\ /usr/local/MATLAB/MATLAB_Runtime/R2026a/sys/os/glnxa64:\ /usr/local/MATLAB/MATLAB_Runtime/R2026a/extern/bin/glnxa64"Note
Before R2025a: If you require Mesa Software OpenGL® rendering to resolve low level graphics issues, add the folder
to the path.<MATLAB_RUNTIME_INSTALL_DIR>/sys/opengl/lib/glnxa64Display the new value of
LD_LIBRARY_PATHto ensure the path is correct.echo $LD_LIBRARY_PATHType
ldd --versionto check your version of GNU® C library (glibc). If the version displayed is 2.17 or lower, addto the<MATLAB_RUNTIME_INSTALL_DIR>/bin/glnxa64/glibc-2.17_shim.soLD_PRELOADenvironment variable using the following command.export LD_PRELOAD="${LD_PRELOAD:+${LD_PRELOAD}:}\ /usr/local/MATLAB/MATLAB_Runtime/R2026a/bin/glnxa64/glibc-2.17_shim.so"To make these changes permanent, see Set Library Paths Permanently.
macOS
Display the current value of
DYLD_LIBRARY_PATHin the terminal.echo $DYLD_LIBRARY_PATHAppend the MATLAB Runtime folders to the
DYLD_LIBRARY_PATHvariable for the current session.For example, if you are using MATLAB Runtime R2026a located in the default installation folder, use the following command.
export DYLD_LIBRARY_PATH="${DYLD_LIBRARY_PATH:+${DYLD_LIBRARY_PATH}:}\ /Applications/MATLAB/MATLAB_Runtime/R2026a/runtime/maca64:\ /Applications/MATLAB/MATLAB_Runtime/R2026a/bin/maca64:\ /Applications/MATLAB/MATLAB_Runtime/R2026a/sys/os/maca64:\ /Applications/MATLAB/MATLAB_Runtime/R2026a/extern/bin/maca64"Display the value of
DYLD_LIBRARY_PATHto ensure the path is correct.echo $DYLD_LIBRARY_PATHTo make these changes permanent, see Set Library Paths Permanently.
Set Library Paths Permanently
Windows
The permanent PATH setting is already covered in the Windows section using the System Properties dialog.
Linux and macOS
To set library paths permanently on Linux or macOS:
Determine your shell by running:
echo $SHELLAdd the export command to your shell configuration file:
For the Bash shell, edit
~/.bash_profileor~/.bashrc.For Zsh, edit
~/.zprofileor~/.zshrc.
Add the appropriate directories from the Linux or macOS sections above using the export command.
For example, if you are using Linux with the Bash shell and MATLAB Runtime R2026a located in the default installation folder, add the following command to
~/.bashrc.export LD_LIBRARY_PATH="${LD_LIBRARY_PATH:+${LD_LIBRARY_PATH}:}\ /usr/local/MATLAB/MATLAB_Runtime/R2026a/runtime/glnxa64:\ /usr/local/MATLAB/MATLAB_Runtime/R2026a/bin/glnxa64:\ /usr/local/MATLAB/MATLAB_Runtime/R2026a/sys/os/glnxa64:\ /usr/local/MATLAB/MATLAB_Runtime/R2026a/extern/bin/glnxa64"Save the file and reload it in the current session to apply changes.
source ~/.bashrc # Bash source ~/.zshrc # Zsh
Caution
Setting MATLAB library paths permanently may cause conflicts with other applications that use the same library paths. Consider these alternatives:
Set paths only for the current session during testing.
Use application-specific wrapper scripts that set the environment before execution.