Main Content

Set Run-Time Library Path for C++ Interface

If the C++ library has a shared library file, then that file and its dependencies must be on your system path or run-time search path (rpath). If the library is completely defined in header or source files, then there might not be a shared library file. The publisher provides information about the library files.

You can set the path each time that you work on the library or set it permanently by setting values in the system environment. To add the library to the system path permanently, refer to your operating system documentation.

Temporarily Set Run-Time Library Path in MATLAB on Windows

On Windows® platforms, if the shared library files are located on rtPath, then in MATLAB® call:

dllPath = 'rtPath'; 
syspath = getenv('PATH'); 
setenv('PATH',[dllPath ';' syspath]);

Note

If you use these commands, then you must set the path each time that you start MATLAB.

Temporarily Set Run-Time Library Path at System Prompt

To set the run-time library path rtPath temporarily, run one of these commands before you start MATLAB. You must restart MATLAB from this system prompt.

  • Windows Command Processor:

    set PATH=rtPath;%PATH%
  • Linux® C shell:

    setenv LD_LIBRARY_PATH rtPath
  • Linux Bourne shell:

    LD_LIBRARY_PATH=rtPath:LD_LIBRARY_PATH
    export LD_LIBRARY_PATH
  • macOS C shell:

    setenv DYLD_LIBRARY_PATH matlabroot/bin/maci64:matlabroot/sys/os/maci64
  • macOS Bourne shell:

    DYLD_LIBRARY_PATH=matlabroot/bin/maci64:matlabroot/sys/os/maci64:DYLD_LIBRARY_PATH 
    export DYLD_LIBRARY_PATH

Note

Start MATLAB in the same operating system prompt where you set the PATH variable. To verify the updated system path, in MATLAB type:

getenv('PATH')

Note

If you use these commands, then you must set the path each time that you open the operating system prompt.

Related Topics