Invalid MEX-file: Library not loaded: @rpath/libMatlabEngine.dylib
23 views (last 30 days)
Show older comments
I wrote a C++ function that I'd like to execute in Matlab via mex. When I compile it:
>> mex kernels/string/ssk.cpp -outdir kernels/string/
Building with 'Xcode Clang++'.
ld: warning: -undefined error is deprecated
ld: warning: -undefined error is deprecated
MEX completed successfully.
it seems to work. However upon execution I get:
---------
Error ID:
---------
'MATLAB:mex:ErrInvalidMEXFile'
--------------
Error Details:
--------------
Invalid MEX-file '/Users/matthias/Documents/uni/Bachelor Thesis/kMRCD/kernels/string/ssk.mexmaci64': dlopen(/Users/matthias/Documents/uni/Bachelor
Thesis/kMRCD/kernels/string/ssk.mexmaci64, 0x0006): Library not loaded: @rpath/libMatlabEngine.dylib
Referenced from: <E31D1387-76D0-3FBE-8950-A48189E53ECF> /Users/matthias/Documents/uni/Bachelor Thesis/kMRCD/kernels/string/ssk.mexmaci64
Reason: tried: '/Applications/MATLAB_R2023b.app/bin/maci64/libMatlabEngine.dylib' (no such file),
'/Applications/MATLAB_R2023b.app/bin/maci64/./libMatlabEngine.dylib' (no such file),
'/Applications/MATLAB_R2023b.app/bin/maci64/../../sys/os/maci64/libMatlabEngine.dylib' (no such file),
'/Applications/MATLAB_R2023b.app/bin/maci64/libMatlabEngine.dylib' (no such file), '/Applications/MATLAB_R2023b.app/bin/maci64/./libMatlabEngine.dylib' (no such
file), '/Applications/MATLAB_R2023b.app/bin/maci64/../../sys/os/maci64/libMatlabEngine.dylib' (no such file),
'/Applications/MATLAB_R2023b.app/bin/maci64/../../runtime/maci64/libMatlabEngine.dylib' (no such file),
'/Applications/MATLAB_R2023b.app/bin/maci64/../../sys/java/jre/maci64/jre/lib/server/libMatlabEngine.dylib' (no such file),
'/Applications/MATLAB_R2023b.app/bin/maci64/../../sys/java/jre/maci64/jre/lib/libMatlabEngine.dylib' (no such file)
when I look for the missing file:
> find /Applications/MATLAB_R2023b.app -name "libMatlabEngine.dylib" [091114b]
/Applications/MATLAB_R2023b.app/extern/bin/maci64/libMatlabEngine.dylib
I find it. I also set my DYLD_LIBRARY_PATH:
> echo $DYLD_LIBRARY_PATH
/Applications/MATLAB_R2023b.app/runtime/maci64:/Applications/MATLAB_R2023b.app/bin/maci64:/Applications/MATLAB_R2023b.app/sys/os/maci64:/Applications/MATLAB_R2023b.app/extern/bin/maci64
but it still can't find it...
I found this question: https://www.mathworks.com/matlabcentral/answers/2044762-why-do-i-receive-a-library-not-loaded-rpath-libmatlabengine-dylib-error-when-running-a-mex-funct that references some archive with correct options which I can't find.
1 Comment
Gowtham
on 2 Jan 2024
Hi Matthias,
Please find the External Bug Report which contains the required zip archive at https://www.mathworks.com/support/bugreports/details/3138142
Alternatively, it is recommended to update MATLAB to R2023b Update 5, which should also resolve the issue.
Answers (0)
See Also
Categories
Find more on MATLAB Compiler in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!