安装openblas和matcaffe时遇到的问题

1.在安装openblas时,报错:/usr/bin/ld: cannot find -lgfortran

这里是需要安装的是libgfortran-x.x-dev,“x.x”是版本名。使用sudo apt-cache search libgfortran看看是否能找到合适的安装包,像我找的就是第一个libgfortran-4.7-dev,因为我的编译器gcc是4.7的(我猜的),但是好使。

2.由于安装了各种依赖库,发现caffe编译出现问题,报出错误如下:

.build_release/lib/libcaffe.so:对‘cv::imread(cv::String const&, int)’未定义的引用
.build_release/lib/libcaffe.so:对‘cv::imencode(cv::String const&, cv::_InputArray const&, std::vector<unsigned char, std::allocator<unsigned char> >&, std::vector<int, std::allocator<int> > const&)’未定义的引用
.build_release/lib/libcaffe.so:对‘cv::imdecode(cv::_InputArray const&, int)’未定义的引用
collect2: 错误: ld 返回 1
make: *** [.build_release/tools/upgrade_net_proto_text.bin] 错误 1

所以出现上面的错误,应该是opencv_imgcodecs链接的问题,比较有效的解决方案是,把opencv需要的lib添加到Makefile文件中,找到LIBRARIES(在PYTHON_LIBRARIES := boost_python python2.7 前一行)并修改为:

LIBRARIES += glog gflags protobuf leveldb snappy \         
lmdb boost_system hdf5_hl hdf5 m \
opencv_core opencv_highgui opencv_imgproc opencv_imgcodecs

每次需要重新编译的过程中,首先需要清除掉以往编译的结果:

$ make clean
$ make
即可
 


原文地址:https://www.cnblogs.com/GingerZeng/p/5775801.html