库未加载:Matlab中的@ loader_path/libmex.dylib [英] Library not loaded: @loader_path/libmex.dylib in matlab
问题描述
macos high sierra 10.13.1 xcode 9.2 matlab 2017b
macos high sierra 10.13.1 xcode 9.2 matlab 2017b
在2017b版本的Mac matlab中运行程序时,我尝试从此链接运行pmtk3运行时,我在运行第二条命令时遇到以下错误
while running a program in mac matlab in 2017b version, I tried to run pmtk3 from this link and while running I got the following error while running second command
- 步骤:
- 运行initPmtk3.m(需要几分钟)
- 运行testPmtk3.m(需要一分钟)
- 运行runDemos.m(大约需要1个小时)
错误:
'/Users/laxmikadariya/Documents/MATLAB/pmtk3-master/pmtksupportCopy/markSchmidt-9march2011/markSchmidt/minFunc/lbfgsC.mexmaci64':
dlopen(/Users/laxmikadariya/Documents/MATLAB/pmtk3-master/pmtksupportCopy/markSchmidt-9march2011/markSchmidt/minFunc/lbfgsC.mexmaci64,
6): Library not loaded: @loader_path/libmex.dylib
Referenced from:
/Users/laxmikadariya/Documents/MATLAB/pmtk3-master/pmtksupportCopy/markSchmidt-9march2011/markSchmidt/minFunc/lbfgsC.mexmaci64
Reason: image not found.
如何在matlab mac中解决此问题?
How can I solve this issue in matlab mac?
我尝试将.bash_profile中的DYLD_LIBRARY_PATH设置为 DYLD_LIBRARY_PATH ='/Applications/MATLAB_R2017b.app/bin/maci64:/Applications/MATLAB_R2017b.app/sys/os/maci64'
I tried to set DYLD_LIBRARY_PATH in .bash_profile as DYLD_LIBRARY_PATH='/Applications/MATLAB_R2017b.app/bin/maci64:/Applications/MATLAB_R2017b.app/sys/os/maci64'
这不能解决问题
推荐答案
lbfgsC.mexmaci64
文件已预编译,并带有2012年的时间戳.此后,MacOS上发生了很多变化...:)
The lbfgsC.mexmaci64
file comes pre-compiled, and with a time-stamp from 2012. Many things have changed on MacOS since then... :)
在终端窗口中,我尝试过:
In a terminal window, I tried:
$> otool -L lbfgsC.mexmaci64
lbfgsC.mexmaci64:
@loader_path/libmx.dylib (compatibility version 0.0.0, current version 0.0.0)
@loader_path/libmex.dylib (compatibility version 0.0.0, current version 0.0.0)
@loader_path/libmat.dylib (compatibility version 0.0.0, current version 0.0.0)
/usr/lib/libstdc++.6.dylib (compatibility version 7.0.0, current version 7.4.0)
/usr/lib/libgcc_s.1.dylib (compatibility version 1.0.0, current version 1.0.0)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 111.1.4)
如您所见,
它使用@loader_path
引用了MATLAB的库,这是错误的.应该是@rpath
.
As you can see, it references MATLAB's libraries using @loader_path
, which is wrong. That should be @rpath
.
我尝试从MATLAB命令提示符下重新编译MEX文件:
I tried recompiling the MEX-file, from the MATLAB command prompt:
>> cd pmtk3/pmtksupportCopy/markSchmidt-9march2011/markSchmidt/minFunc
>> mex -compatibleArrayDims lbfgsC.c
-compatibleArrayDims
选项是必需的,因为代码很旧,并且使用int
表示数组大小(32位),而不是mwSize
(64位).
The -compatibleArrayDims
option is necessary because the code is very old, and uses int
for array sizes (32 bits), rather than mwSize
(64 bits).
在终端窗口中,我现在看到:
In a terminal window I now see:
$> otool -L lbfgsC.mexmaci64
lbfgsC.mexmaci64:
@rpath/libmx.dylib (compatibility version 0.0.0, current version 0.0.0)
/usr/lib/libc++.1.dylib (compatibility version 1.0.0, current version 400.9.0)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1252.0.0)
这看起来好多了,它应该使用@rpath
. MEX文件现在已运行,这意味着链接程序问题已解决.
This looks a lot better, it's using @rpath
as it should. The MEX-file now ran, meaning that the linker problem is solved.
在同一目录中还有另一个MEX文件,它将具有相同的问题.您必须同时编译该文件:
There is another MEX-file in this same directory, it will have the same problem. You'll have to compile that one at the same time:
>> mex -compatibleArrayDims mcholC.c
这篇关于库未加载:Matlab中的@ loader_path/libmex.dylib的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!