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 个评论
Walter Roberson
2018-6-3
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.
Haneya Qureshi
2018-6-3
编辑:Haneya Qureshi
2018-6-3
Walter Roberson
2018-6-3
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
Haneya Qureshi
2018-6-3
编辑:Haneya Qureshi
2018-6-3
Raymond MacNeil
2019-6-12
@Walter Roberson
Thanks, this fixed my issue.
Samuel L. Polk
2021-5-6
编辑:Samuel L. Polk
2021-5-6
@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
Walter Roberson
2021-5-6
You might have to put it into /usr/lib
Samuel L. Polk
2021-5-6
@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
However:
- in newer releases of MacOS, /usr/lib is controlled by System Integrity Protection, and it might be necessary to use csrutil to disable SIP to write to the directory
- starting from Big Sur, the root file system is "sealed", and you might need to unseal it, make the change to /usr/lib, and re-seal it afterwards; see https://eclecticlight.co/2020/06/25/big-surs-signed-system-volume-added-security-protection/
- I have seen a claim that you can write to /usr/local/lib instead of /usr/lib, and I see in the documentation for SIP that /usr/local is not protected. I do not know if this will work
- it looks like there may be approaches using install_name_change to modify MATLAB's idea of its library paths; https://briandfoy.github.io/macos-s-system-integrity-protection-sanitizes-your-environment/
- You might be able to modify rpath; see https://medium.com/@donblas/fun-with-rpath-otool-and-install-name-tool-e3e41ae86172
- However... although SIP is not supposed to affect MATLAB because it is not a "system executable" provided by Apple, in practice people observe that it does affect MATLAB because MATLAB is typically inside /Applications . And that implies that you might potentially need special steps to modify MATLAB's rpath .
回答(1 个)
Omar Shadeed
2019-4-24
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!