Main Content

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_application.sh) on Linux or macOS to launch an application.

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 Run Applications Using a Network Installation of MATLAB Runtime.

Library Path Environment Variables and MATLAB Runtime Folders

Operating SystemEnvironment VariableDirectories
WindowsPATH<MATLAB_RUNTIME_INSTALL_DIR>\runtime\<arch>
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 (Intel® processor)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

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 R2023b located in the default installation folder on 64-bit Windows, add C:\Program Files\MATLAB\MATLAB Runtime\R2023b\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.

    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 folder <MATLAB_RUNTIME_INSTALL_DIR>/sys/opengl/lib/glnxa64 to the path. For details, see Resolving Low-Level Graphics Issues.

    For example, if you are using MATLAB Runtime R2023b 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/R2023b/runtime/glnxa64:\
    /usr/local/MATLAB/MATLAB_Runtime/R2023b/bin/glnxa64:\
    /usr/local/MATLAB/MATLAB_Runtime/R2023b/sys/os/glnxa64:\
    /usr/local/MATLAB/MATLAB_Runtime/R2023b/extern/bin/glnxa64"

  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}:}\
    <MATLAB_RUNTIME_INSTALL_DIR>/bin/glnxa64/glibc-2.17_shim.so"

  5. To make these changes permanent, see Set Path Permanently on UNIX.

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 Intel processor-based macOS, use the following command.

    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 Apple silicon-based macOS, use the following command.

    export DYLD_LIBRARY_PATH="${DYLD_LIBRARY_PATH:+${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"

    For example, if you are using MATLAB Runtime R2023b on Intel processor-based macOS located in the default installation folder, use the following command.

    export DYLD_LIBRARY_PATH="${DYLD_LIBRARY_PATH:+${DYLD_LIBRARY_PATH}:}\
    /Applications/MATLAB/MATLAB_Runtime/R2023b/runtime/maci64:\
    /Applications/MATLAB/MATLAB_Runtime/R2023b/bin/maci64:\
    /Applications/MATLAB/MATLAB_Runtime/R2023b/sys/os/maci64:\
    /Applications/MATLAB/MATLAB_Runtime/R2023b/extern/bin/maci64"

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

Related Topics