MATLAB Answers

Invalid Mex-files using 2018a Xcode 9.2

40 views (last 30 days)
Eric Elharer
Eric Elharer on 28 Mar 2018
Commented: Eric Elharer on 5 Dec 2019
While trying to run Matlab 2018a code using "BM3D" downloaded from from (the file is I'm getting this errors.
tried almost every solution suggested on Matlab Answers Community with no success.
I'm using Xcode 9.2.
Invalid MEX-file '/Users/ericelharar/Documents/MATLAB/Eric_Pedro/BM3D/bm3d_thr.mexmaci64': dlopen(/Users/ericelharar/Documents/MATLAB/Eric_Pedro/BM3D/bm3d_thr.mexmaci64,
6): Library not loaded: @loader_path/libmat.dylib
Referenced from: /Users/ericelharar/Documents/MATLAB/Eric_Pedro/BM3D/bm3d_thr.mexmaci64
Reason: image not found.
Error in BM3D (line 342)
y_hat = bm3d_thr(z, hadper_trans_single_den, Nstep, N1, N2, lambda_thr2D,...


Show 4 older comments
Walter Roberson
Walter Roberson on 13 Jan 2019
The original poster mentioned XCode 9.2, which is for MacOS 10.12.6+ onward, which is for Sierra; High Sierra needs XCode 9.3 or later.
MacOS Sierra was the release where Apple starting getting serious with System Integrity Protection, which turns off recognition of DYLD_DYNAMIC_PATH in some cases. This wasn't a MATLAB issue; it was an Apple issue. Individual programs could adapt to the Apple restriction, but the most obvious adaptation is to static link libraries instead of using DLL. For third-party packages such as BM3D, that would involve a change to BM3D rather than a change to MATLAB.
Eric Elharer
Eric Elharer on 22 Oct 2019
Hi I received a beta version for Bm3d which solves this problem If interested I will forward the file with the instructions
Wen Ying
Wen Ying on 5 Dec 2019
hi I meet the same problem, and i use matlab2018a and xcode11.2.1 macos 10.14.6.
i did not find the function the solve this issue.
could you send me the beta version for bm3d?

Sign in to comment.

Answers (1)

Walter Roberson
Walter Roberson on 28 Mar 2018
Sierra and High Sierra ignore DYLD_DYNAMIC_PATH in some cases, for security reasons. It is only intended to apply to some executables, but likely it is interfering.
tl;dr -- put copies of the library in /usr/lib


Show 7 older comments
Yilin Lin
Yilin Lin on 31 May 2018
I am facing the exact same issue - please let me know when you get it to work! Thanks a lot.
Zhihong Pan
Zhihong Pan on 21 Oct 2019
stuck at the same error on MacOS, any updates on this?
Eric Elharer
Eric Elharer on 5 Dec 2019
Hi Send me a gmail address mail and I'll share with u a folder with all the information and software updates that helped me Hope it would work for u 2

Sign in to comment.