MATLAB Answers

Invalid MEX-file MacOS

152 views (last 30 days)
Jakob Ketterer
Jakob Ketterer on 9 Nov 2020
Commented: Walter Roberson on 12 Nov 2020
Hi,
i want to install the biomechanical toolkit to matlab (2020b). I am using MacOs 10.15.7. However, i get this error about missing libraries:
Invalid MEX-file '/Users/jakobketterer/Documents/MATLAB/btk/btkReadAcquisition.mexmaci64':
dlopen(/Users/jakobketterer/Documents/MATLAB/btk/btkReadAcquisition.mexmaci64, 6): Library not loaded:
@loader_path/libmex.dylib
Referenced from: /Users/jakobketterer/Documents/MATLAB/btk/btkReadAcquisition.mexmaci64
Reason: image not found
When i copy the 'libmex.dylib' file from fullfile(matlabroot, 'bin/maci64/libmex.dylib') and place it in the folder of the toolbox, another error appears asking for the 'libeng.dylib' file. After copying this, the follwoing error is shown:
Invalid MEX-file '/Users/jakobketterer/Documents/MATLAB/btk/btkReadAcquisition.mexmaci64':
dlopen(/Users/jakobketterer/Documents/MATLAB/btk/btkReadAcquisition.mexmaci64, 6): Symbol not found:
__ZN8Mlm_file11get_aspectsERiS0_S0_RbS1_S1_
Referenced from: /Users/jakobketterer/Documents/MATLAB/btk/libmex.dylib
Expected in: /Applications/MATLAB_R2020b.app/bin/maci64/libmwm_dispatcher.dylib
in /Users/jakobketterer/Documents/MATLAB/btk/libmex.dylib

Answers (1)

Rajat Tewari
Rajat Tewari on 12 Nov 2020
  1 Comment
Walter Roberson
Walter Roberson on 12 Nov 2020
MacOS Sierra and later have System Integrity Protection features that can prevent dll from being loaded for applications that live in /Applications unless the dll is put into /usr/lib . The security feature was only supposed to affect Apple supplied software but in practice most things in /Applications are affected. MacOs Catalina split the operating system and put major parts into a protected file system, which I suspect makes it more difficult for a user to modify /usr/lib .
It is Apple's intention that applications installed in /Applications should only be able to access system DLLs and DLLs provided with the application and signed with the Developer's certificate. It is explicitly intended that users will not be able to install DLLs for use by multiple programs, that the DLLs must be part of each application that they are used with. The claim is that this will prevent cross-program attacks, preventing a process from contaminating a DLL that is in use by another process.
This is a significant part of the reason that Nvidia will no longer support Apple. Apple declined to certify Nvidia drivers as part of the operating system, and now the Nvidia drivers would have to be supplied with each application individually.
I do not know how this will affect MATLAB's ability to call DLLs, but according to a few posts it has already made it necessary to install some DLLs into /usr/lib instead of in user directories.
This is not just a matter of ensuring that the LD_LIBRARY_PATH includes the DLLs: the security features are actively ignoring that for protected programs (and more things are protected than should be.)
The effect is similar in some ways to how LD_LIBRARY_PATH has always been ignored for suid and sguid executables.

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!