dyld: Library not loaded: @rpath/libpython3.7m.dylib(太忙了,先记录下来,过几天完善)
编译caffe时,执行sudo make runtest报错:
.build_release/tools/caffe
dyld: Library not loaded: @rpath/libpython3.7m.dylib
Referenced from: /Users/apple/caffe/.build_release/tools/caffe
Reason: image not found
make: *** [runtest] Abort trap: 6
方法一:添加环境变量
- 利用otool查看动态依赖库
otool -L .build_release/tools/caffe - 找到@rpath/libpython3.7m.dylib (compatibility version 3.7.0, current version 3.7.0)
加载器首先看有没有 RUNPATH, 如果有那么就尝试从LD_LIBRARY_PATH 加载,如果还是失败再从RUNPATH加载。当然最后如果还是不行,会尝试 /lib 和 /usr/lib。[1] - 查看环境变量:
LD_LIBRARY_PATH=/Users/apple/anaconda3/lib:
我需要的是/usr/local/lib,因此添加环境变量就行。这个方法我在遇到其它类似的问题时已经成功使用过。这里尝试换一种方法解决,见方法二。
方法二:使用install_name_tool
- 更改动态库查找路径install_name_tool -change src_dir dst_dir obj [2]
- 我需要添加动态库查找路径,执行下面这段语句:
sudo install_name_tool -add_rpath /Users/apple/anaconda3/lib ~/caffe/.build_release/tools/caffe
再sudo make runtest,成功!