我使用的版本是3.1.0
,在编译工程的时候,遇到如下BUG
...CXX/LD -o .build_release/tools/convert_imageset.bin .build_release/lib/libcaffe.so:
undefined reference to cv::imread(cv::String const&, int)’ .build_release/lib/libcaffe.so:
undefined reference tocv::imencode(cv::String const&, cv::_InputArray const&, std::vector >&, std::vector > const&)’ .build_release/lib/libcaffe.so:
undefined reference to `cv::imdecode(cv::_InputArray const&, int)’
collect2: error: ld returned 1 exit status
make: * [.build_release/tools/convert_imageset.bin] Error 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