Main Content

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 SystemEnvironment VariableDirectories
WindowsPATH<MATLAB_RUNTIME_INSTALL_DIR>\runtime\win64
LinuxLD_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

macOS (Apple silicon)DYLD_LIBRARY_PATH

<MATLAB_RUNTIME_INSTALL_DIR>/runtime/maca64

<MATLAB_RUNTIME_INSTALL_DIR>/bin/maca64

<MATLAB_RUNTIME_INSTALL_DIR>/sys/os/maca64

<MATLAB_RUNTIME_INSTALL_DIR>/extern/bin/maca64

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.

  1. Run C:\Windows\System32\SystemPropertiesAdvanced.exe and click the Environment Variables... button.

  2. 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.

  3. 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.

  4. 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

  1. Display the current value of LD_LIBRARY_PATH in the terminal.

    echo $LD_LIBRARY_PATH

  2. Append the MATLAB Runtime folders to the LD_LIBRARY_PATH variable 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 <MATLAB_RUNTIME_INSTALL_DIR>/sys/opengl/lib/glnxa64 to the path.

  3. Display the new value of LD_LIBRARY_PATH to ensure the path is correct.

    echo $LD_LIBRARY_PATH

  4. Type ldd --version to check your version of GNU® C library (glibc). If the version displayed is 2.17 or lower, add <MATLAB_RUNTIME_INSTALL_DIR>/bin/glnxa64/glibc-2.17_shim.so to the LD_PRELOAD environment 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"

  5. To make these changes permanent, see Set Library Paths Permanently.

macOS

  1. Display the current value of DYLD_LIBRARY_PATH in the terminal.

    echo $DYLD_LIBRARY_PATH

  2. Append the MATLAB Runtime folders to the DYLD_LIBRARY_PATH variable 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"

  3. Display the value of DYLD_LIBRARY_PATH to ensure the path is correct.

    echo $DYLD_LIBRARY_PATH

  4. To 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:

  1. Determine your shell by running:

    echo $SHELL
    
  2. Add the export command to your shell configuration file:

    • For the Bash shell, edit ~/.bash_profile or ~/.bashrc.

    • For Zsh, edit ~/.zprofile or ~/.zshrc.

  3. 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"

  4. 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.

See Also

Topics