Set MATLAB Library Paths for Testing Deployed Applications
Note
If you're preparing your application for end-user deployment rather than development testing, see Set MATLAB Runtime Library Paths for Deployment.
When developing applications with MATLAB® Compiler™ or MATLAB Compiler SDK™, use your existing MATLAB installation instead of a separate MATLAB Runtime installation for testing. This approach reduces development time and maintains consistency between development and testing environments.
The development cycle typically involves compiling, testing, debugging, and recompiling applications multiple times. Configure your system to use the libraries from your MATLAB installation to test your compiled applications without installing and configuring MATLAB Runtime for each test iteration.
On the development machine, you can test your application's execution by issuing
!
at the MATLAB prompt. This will verify that library dependencies are correct, that the
deployable archive can be extracted, and that all MATLAB code, MEX—files and support files required by the application have
been included in the archive. To test applications using MATLAB from the system command line, follow the instructions in this topic to
configure your system library path for testing with your MATLAB installation. This configuration uses the same core libraries that
MATLAB Runtime provides, but accesses them directly from your MATLAB installation folders. The final deployed application requires MATLAB Runtime on end-user systems.application-name
Library Path Environment Variables and MATLAB Folders
| Operating System | Environment Variable | Folders |
|---|---|---|
| Windows® | PATH | |
| Linux® | LD_LIBRARY_PATH |
|
| macOS (Apple silicon) | DYLD_LIBRARY_PATH |
|
Windows
To configure your Windows system to use MATLAB installation libraries for testing packaged applications:
Determine your MATLAB installation directory by running the
matlabrootcommand in the MATLAB Command Window.Run
C:\Windows\System32\SystemPropertiesAdvanced.exeand click the Environment Variables button.Select the system variable Path and click Edit.
Note
If you do not have administrator rights, select the user variable Path instead.
Click New and add the folder
. For example if using MATLAB R2026a in the default location:<MATLAB_INSTALL_DIR>\runtime\win64C:\Program Files\MATLAB\R2026a\runtime\win64Click OK to apply the change.
Verify the configuration by opening a new Command Prompt window and running:
echo %PATH%
Note
If multiple MATLAB versions exist in your PATH, applications use the first version listed. Ensure your development version appears first for consistent testing.
Linux
To configure your Linux system to use MATLAB installation libraries for testing packaged applications:
Determine your MATLAB installation directory by running the
matlabrootcommand in the MATLAB Command Window.Display the current value of
LD_LIBRARY_PATHin the terminal:echo $LD_LIBRARY_PATHAppend the MATLAB library folders to the
LD_LIBRARY_PATHvariable for the current session:export LD_LIBRARY_PATH="${LD_LIBRARY_PATH:+${LD_LIBRARY_PATH}:}\ <MATLAB_INSTALL_DIR>/runtime/glnxa64:\ <MATLAB_INSTALL_DIR>/bin/glnxa64:\ <MATLAB_INSTALL_DIR>/sys/os/glnxa64:\ <MATLAB_INSTALL_DIR>/extern/bin/glnxa64"For example, if your MATLAB is installed in
/usr/local/MATLAB/R2026a:export LD_LIBRARY_PATH="${LD_LIBRARY_PATH:+${LD_LIBRARY_PATH}:}\ /usr/local/MATLAB/R2026a/runtime/glnxa64:\ /usr/local/MATLAB/R2026a/bin/glnxa64:\ /usr/local/MATLAB/R2026a/sys/os/glnxa64:\ /usr/local/MATLAB/R2026a/extern/bin/glnxa64"Verify the updated path:
echo $LD_LIBRARY_PATHCheck your GNU C library (
glibc) version:ldd --versionIf the version is 2.17 or lower, add the
glibcshim to theLD_PRELOADenvironment variable:export LD_PRELOAD="${LD_PRELOAD:+${LD_PRELOAD}:}\ <MATLAB_INSTALL_DIR>/bin/glnxa64/glibc-2.17_shim.so"
Note
Add <MATLAB_INSTALL_DIR>/sys/opengl/lib/glnxa64 to your
LD_LIBRARY_PATH if you encounter graphics issues.
These instructions are for the Bash shell. For other shells, refer to your shell documentation.
macOS
To configure your macOS system to use MATLAB installation libraries for testing compiled applications:
Determine your MATLAB installation directory by running the
matlabrootcommand in the MATLAB Command Window.Display the current value of
LD_LIBRARY_PATHin the terminal:echo $DYLD_LIBRARY_PATHAppend the MATLAB library folders to
DYLD_LIBRARY_PATH:export DYLD_LIBRARY_PATH="${DYLD_LIBRARY_PATH:+${DYLD_LIBRARY_PATH}:}\ <MATLAB_INSTALL_DIR>/runtime/maca64:\ <MATLAB_INSTALL_DIR>/bin/maca64:\ <MATLAB_INSTALL_DIR>/sys/os/maca64:\ <MATLAB_INSTALL_DIR>/extern/bin/maca64"For example, with MATLAB installed in
/Applications/MATLAB_R2026a.app:export DYLD_LIBRARY_PATH="${DYLD_LIBRARY_PATH:+${DYLD_LIBRARY_PATH}:}\ /Applications/MATLAB_R2026a.app/runtime/maca64:\ /Applications/MATLAB_R2026a.app/bin/maca64:\ /Applications/MATLAB_R2026a.app/sys/os/maca64:\ /Applications/MATLAB_R2026a.app/extern/bin/maca64"Verify the updated path:
echo $DYLD_LIBRARY_PATH
These instructions are for the Bash or Zsh shell. For other shells, refer to your shell documentation.
Note
On macOS, System Integrity Protection (SIP) may prevent
DYLD_LIBRARY_PATH from being passed to child processes.
You may need to run your application from the same terminal session where you
set the environment variable.
Set Library Paths Permanently
While setting paths temporarily is recommended for testing, you can set them permanently if needed:
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 commands to your shell configuration file:
For bash shell, edit
~/.bash_profileor~/.bashrcand add the appropriate export commands from the Linux or macOS sections above.For Zsh, edit
~/.zprofileor~/.zshrcand add the appropriate export commands from the Linux or macOS sections above.
Save the file and reload it.
source ~/.bashrc # For Bash source ~/.zshrc # For 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.
For production deployment, always use MATLAB Runtime instead of relying on a MATLAB installation. For details, see Set MATLAB Runtime Library Paths for Deployment.