编译caffe时遇到CXX/LD -o .build_release/examples/siamese/convert_mnist_siamese_data.bin .build_release/li

我电脑上本来是有编译好的caffe的,但是由于要跑的代码里作者自带了caffe,为了防止后续跑代码时不必要的麻烦,索性就重新按照作者的方法编译了一下caffe(不过是在另一个分支上进行的,并不影响我原来的caffe)。于是乎就遇到了问题:

CXX/LD -o .build_release/examples/siamese/convert_mnist_siamese_data.bin
.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 >&, std::vector > const&)’未定义的引用
.build_release/lib/libcaffe.so:对‘cv::imdecode(cv::_InputArray const&, int)’未定义的引用
collect2: error: ld returned 1 exit status
make: *** [.build_release/tools/extract_features.bin] 错误 1
make: *** 正在等待未完成的任务....
.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 >&, std::vector > const&)’未定义的引用
.build_release/lib/libcaffe.so:对‘cv::imdecode(cv::_InputArray const&, int)’未定义的引用
collect2: error: ld returned 1 exit status
make: *** [.build_release/examples/cifar10/convert_cifar_data.bin] 错误 1
.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 >&, std::vector > const&)’未定义的引用
.build_release/lib/libcaffe.so:对‘cv::imdecode(cv::_InputArray const&, int)’未定义的引用
collect2: error: ld returned 1 exit status
make: *** [.build_release/tools/compute_image_mean.bin] 错误 1
.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 >&, std::vector > const&)’未定义的引用
.build_release/lib/libcaffe.so:对‘cv::imdecode(cv::_InputArray const&, int)’未定义的引用
collect2: error: ld returned 1 exit status
make: *** [.build_release/tools/convert_imageset.bin] 错误 1
.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 >&, std::vector > const&)’未定义的引用
.build_release/lib/libcaffe.so:对‘cv::imdecode(cv::_InputArray const&, int)’未定义的引用
collect2: error: ld returned 1 exit status
make: *** [.build_release/examples/mnist/convert_mnist_data.bin] 错误 1
.build_release/lib/libcaffe.so:对‘cv::imread(cv::String const&, int)’未定义��.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 >&, std::vector > const&)’未定义的引用
.build_release/lib/libcaffe.so:对‘cv::imdecode(cv::_InputArray const&, int)’未定义的引用
�collect2: error: ld returned 1 exit status
引用
.build_release/make: *** [.build_release/tools/upgrade_net_proto_text.bin] 错误 1
lib/libcaffe.so:对‘cv::imencode(cv::String const&, cv::_InputArray const&, std::vector >&, std::vector > const&)’未定义的引用
.build_release/lib/libcaffe.so:对‘cv::imdecode(cv::_InputArray const&, int)’未定义的引用
collect2: error: ld returned 1 exit status
make: *** [.build_release/tools/caffe.bin] 错误 1
.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 >&, std::vector > const&)’未定义的引用
.build_release/lib/libcaffe.so:对‘cv::imdecode(cv::_InputArray const&, int)’未定义的引用
collect2: error: ld returned 1 exit status
make: *** [.build_release/tools/upgrade_net_proto_binary.bin] 错误 1
.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 >&, std::vector > const&)’未定义的引用
.build_release/lib/libcaffe.so:对‘cv::imdecode(cv::_InputArray const&, int)’未定义的引用

最开始在网上找了好久也没解决,后来经过自己的大胆尝试居然成功解决了,我的方法如下:

首先这个问题确实是opencv的问题,只需要把  Makefile.config里的    #USE_PKG_CONFIG := 这一行前面的#给去掉,然后在他下一行添加

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

保存,然后再编译即可。如果还不可以,试一下把原来的编译内容用make clean清空,再重新编译。如果还不行,那只能靠诸位再继续大胆尝试了。

你可能感兴趣的:(编译caffe时遇到CXX/LD -o .build_release/examples/siamese/convert_mnist_siamese_data.bin .build_release/li)