Main Content

Set Run-Time Library Path on macOS Systems

At run time, tell the operating system where the API shared libraries reside by setting the environment variable DYLD_LIBRARY_PATH. You must start MATLAB® on the same line with the command to set DYLD_LIBRARY_PATH. To set the library path and start MATLAB, type:

DYLD_LIBRARY_PATH=matlabroot/bin/macos:matlabroot/sys/os/macos /matlabexecutable

Replace macos with either maca64 for macOS with Apple silicon or maci64 for macOS with Intel®. Set matlabexecutable to the full path to the MATLAB_macos executable inside the MATLAB application bundle. For example, for MATLAB R2023b, type:

DYLD_LIBRARY_PATH = /Applications/MATLAB_R2023b.app/bin/maca64:/Applications/MATLAB_R2023a.app/sys/os/maca64 /Applications/MATLAB_R2023b.app/Contents/MacOS/MATLAB_maca64

If you have multiple versions of MATLAB installed on your system, the version you use to build your engine applications must be the first listed in your system Path environment variable. Otherwise, MATLAB displays Can't start MATLAB engine.

Set the path every time you run MATLAB.

See Also