MATLAB: Do I receive an error about “libmwlaun​chermain.d​ylib” library not loaded when I attempt to execute the compiled application on macOS

6abortlibmwlaunchermain.dylibMATLAB Compilerruntimetrap:

When I try to execute my compiled application on macOS via the shell script in the "for_testing" directory, why do I receive the following error:
 
$ bash run_untitled.sh /Applications/MATLAB/v92
——————————————
Setting up environment variables
DYLD_LIBRARY_PATH is .:/Users/username/Applications/MATLAB/v92/runtime/maci64:/Users/username/Applications/MATLAB/v92/bin/maci64:/Users/username/Applications/MATLAB/v92/sys/os/maci64
dyld: Library not loaded: @rpath/libmwlaunchermain.dylib
Referenced from: /Users/username/Desktop/untitled/for_testing/./untitled.app/Contents/MacOS/untitled
Reason: image not found
run_untitled.sh: line 29: 7144 Abort trap: 6 "./untitled.app/Contents/MacOS/untitled”

Best Answer

This error indicates the MATLAB Runtime directory specified (i.e. /Applications/MATLAB/v92 in this example) is missing important files.
Make sure the path to the runtime directory is specified correctly. The runtime is generally installed in /Applications/MATLAB/MATLAB_Runtime/v92 (for MATLAB R2017a).
If you have MATLAB R2017a installed on the system, you do not need the runtime. In that case, you would run the application with the following command:
 
bash run_untitled.sh /Applications/MATLAB_R2017a.app
If MATLAB R2017a is not installed on the system, you need the runtime. In that case, this would be the typical command to start the application:
 
bash run_untitled.sh /Applications/MATLAB/MATLAB_Runtime/v92