Invalid MEX-file: Library not loaded: @rpath/lib​MatlabEngi​ne.dylib

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...

1 Comment

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.

Sign in to comment.

Answers (0)

Categories

Find more on MATLAB Compiler in Help Center and File Exchange

Products

Release

R2023b

Asked:

on 22 Dec 2023

Commented:

on 2 Jan 2024

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!