在构建 MatCaffe(Caffe 的 Matlab 包装器)期间,我遇到以下错误:
[ 96%] Built target convert_mnist_data
[ 96%] Built target convert_mnist_siamese_data
[ 98%] Built target pycaffe
[100%] Building Matlab interface: /home/trunks/Downloads/caffe-master/matlab/+caffe/private/caffe_.mexa64
Building with 'g++'.
Warning: You are using gcc version '4.8.2'. The version of gcc is not supported. The version currently supported with MEX is '4.7.x'. For a list of currently supported compilers see: http://www.mathworks.com/support/compilers/current_release.
Warning: You are using gcc version '4.8.2-19ubuntu1)'. The version of gcc is not supported. The version currently supported with MEX is '4.7.x'. For a list of currently supported compilers see: http://www.mathworks.com/support/compilers/current_release.
/usr/bin/ld: cannot find -lpython2
collect2: error: ld returned 1 exit status
make[2]: *** [../matlab/+caffe/private/caffe_.mexa64] Error 255
make[1]: *** [matlab/CMakeFiles/matlab.dir/all] Error 2
make: *** [all] Error 2
经过仔细检查,我发现使用以下命令发现以下文件是造成上述错误的原因:
grep -rnw "./" -e "-lpython2"
它向我揭示了以下内容:
./matlab/CMakeFiles/matlab.dir/build.make:53: cd /home/trunks/Downloads/caffe-master/build/matlab && /usr/local/MATLAB/R2014a/bin/mex -output /home/trunks/Downloads/caffe-master/matlab/+caffe/private/caffe_.mexa64 /home/trunks/Downloads/caffe-master/matlab/+caffe/private/caffe_.cpp -DCPU_ONLY -DWITH_PYTHON_LAYER -DGTEST_USE_OWN_TR1_TUPLE -I/home/trunks/Downloads/caffe-master/src -I/usr/include -I/home/trunks/Downloads/caffe-master/build/external/glog-install/include -I/home/trunks/Downloads/caffe-master/build/external/gflags-install/include -I/home/trunks/Downloads/caffe-master/build/include -I/usr/local/include/opencv -I/usr/local/include -I/usr/include/python2.7 -I/home/trunks/anaconda/lib/python2.7/site-packages/numpy/core/include -I/home/trunks/Downloads/caffe-master/include -I/home/trunks/Downloads/caffe-master/build -L/home/trunks/Downloads/caffe-master/build/lib -L/usr/lib/x86_64-linux-gnu -L/home/trunks/Downloads/caffe-master/build/external/gflags-install/lib -L/home/trunks/Downloads/caffe-master/build/external/glog-install/lib -L/usr/lib -L/usr/local/lib -L/usr/local/lib -L/usr/local/lib -L/usr/local/lib -lcaffe -lboost_system -lboost_thread -lpthread -lgflags -lglog -lhdf5_hl -lhdf5 -llmdb -lleveldb -lsnappy -lopencv_core -lopencv_highgui -lopencv_imgproc -lopencv_imgcodecs -lopenblas -lpython2 -lboost_python -lprotobuf
所以,我把对应的-lpython2改为-lpython2.7,希望能解决问题。但是没有收成。
我还尝试了以下方法:
- 删除 CMakeCache.txt 并进行制作。但它没有用。
我在 /cmake-master 中编辑了默认的 CMakeLists.txt 文件,以更改一些默认设置。我发现 Caffe 的 CMakeLists.txt 中的默认 python 版本设置是 2 。
//指定使用哪个python版本 python_version:STRING=2.7
我将其更改为 2 ,并在一个新的构建文件夹中重复了整个 configure-generate-make 过程。但是没有收成。每次相同的 matlab/build.make 文件显示 -lpython2 时,直接将其更改为 2.7 不会产生。
- 我试图查看 matlab/build.make 文件,但找不到可以直接与此错误相关的任何内容。
任何可靠的帮助将不胜感激。我在 Ubuntu 14.04 上使用 MATLAB 2014a。