invalid mex file and missing libmwblas.dylib error

I am compiling a MATLAB script on mac and i have downloaded Xcode for MEX file integration but I am getting the following error related to some missing libraries:
Invalid MEX-file '/Users/haneya/Desktop/SVT_MostRecent/private/XonOmega.mexmaci64':
dlopen(/Users/haneya/Desktop/SVT_MostRecent/private/XonOmega.mexmaci64, 6): Library not
loaded: @loader_path/libmwblas.dylib
Referenced from: /Users/haneya/Desktop/SVT_MostRecent/private/XonOmega.mexmaci64
Reason: image not found.

9 个评论

Which Mac operating system are you using?
The library should be in fullfile(matlabroot, 'bin/maci64/libmwblas.dylib') but I suspect that is not on your library path, especially if you are using Sierra or High Sierra.
I am using macOS High Sierra Version 10.13.1
What should i do now?
You might be running into difficulties with Apple's System Integrity Protection (SIP), https://support.apple.com/en-ca/HT204899
It is not "supposed to" affect applications such as MATLAB that you install, but people are finding that it does.
What it does is disable paying attention to LD_LIBRARY_PATH for some executables. The work-around sometimes suggested is to put a copy of the library into /usr/lib
Thanks a lot for your suggestions! I copied the library from fullfile(matlabroot, 'bin/maci64/libmwblas.dylib') and placed it in the folder where my matlab script was and it's working perfectly now!
@Walter Roberson
Thanks, this fixed my issue.
@Walter Roberson Hello! I am having the same issue as Haneya. I put a copy of the library into the folder in which my MATLAB script that uses libmwblas.dylib is. However, I am still getting the same error. I was wondering if you have any other suggestions. Thank you!
My specific error is:
Invalid MEX-file
'/Users/sampolk/Documents/MATLAB/Code/DemoMatlabRealData/QPAS/qpas.mexmaci64':
dlopen('/Users/sampolk/Documents/MATLAB/Code/DemoMatlabRealData/QPAS/qpas.mexmaci64', 6): Library not
loaded: @loader_path/libmwblas.dylib
Referenced from:
/Users/sampolk/Documents/MATLAB/Code/DemoMatlabRealData/QPAS
Reason: image not found
You might have to put it into /usr/lib
@Walter Roberson Thank you for your quick response! Unfortunately, I'm having some trouble finding the folder '/user/lib/' in the package contents of the MATLAB software. Could you please describe where that folder is? I am runnning MATLAB R2021a on macOS Big Sur Version 11.2.3 if that is any help. Thank you again for your help.
It was /usr/lib not /user/lib . And it is not inside the MATLAB software, it is a system folder that exists on systems derived from Unix.
!ls /usr/lib
apt dconf gettext groff libgdiplus.so libMonoPosixHelper.so modules-load.d pkg-config.multiarch sasl2 systemd X11 binfmt.d debug girepository-1.0 initramfs-tools libgdiplus.so.0 libMonoSupportW.so mono python2.7 sftp-server tar x86_64-linux-gnu binfmt-support dpkg glib-networking insserv libgdiplus.so.0.0.0 locale openssh python3 software-properties tc xorg cli esmtp gnupg jvm libid3tag.so.0 man-db os-release python3.5 ssl tmpfiles.d compat-ld gcc gold-ld ldscripts libid3tag.so.0.3.0 mime pkgconfig python3.8 syslog-ng valgrind
However:

请先登录,再进行评论。

回答(1 个)

Hi Haneya,
I'm actually having the same error, I copied the libmwblas.dylib file from matlabroot and pasted it in my current matlab directory but I still get the same error.
Note: The mex is done successfully but when I run the Simulinknk model that uses the S-Function I get the same error you got. So what did you do to make it work?
Thanks,
The error I get is:
  • Error while obtaining sizes from MEX S-function 'TrackerObject' in 'DSSDK_TrackerSingleObject/S-Function'.
  • Caused by:
  • Invalid MEX-file '/Users/omarshadeed/Desktop/VICON/Simulink models/DSSDK/SingleObject/TrackerObject.mexmaci64': dlopen(/Users/omarshadeed/Desktop/VICON/Simulink models/DSSDK/SingleObject/TrackerObject.mexmaci64, 6): Library not loaded: @executable_path/libViconDataStreamSDK_CPP.dylib Referenced from: /Users/omarshadeed/Desktop/VICON/Simulink models/DSSDK/SingleObject/TrackerObject.mexmaci64 Reason: image not found.

类别

帮助中心File Exchange 中查找有关 Write C Functions Callable from MATLAB (MEX Files) 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by