old Caffe version + OpenCV 3.1

Problem:

1
caffe: compile error: undefined reference to 'cv::imread(cv::String const&, int)' et al.

when I compile caffe file:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
.build_debug/lib/libcaffe.so: undefined reference to `cv::imread(cv::String const&, int)'
.build_debug/lib/libcaffe.so: undefined reference to `cv::imencode(cv::String const&, cv::_InputArray const&, std::vector<unsigned char, std::allocator<unsigned char> >&, std::vector<int, std::allocator<int> > const&)'
.build_debug/lib/libcaffe.so: undefined reference to `cv::imdecode(cv::_InputArray const&, int)'
collect2: error: ld returned 1 exit status
.build_debug/lib/make: libcaffe.so: undefined *** [.build_debug/tools/upgrade_net_proto_text.bin] Error 1
referencemake: *** Waiting for unfinished jobs....
to `cv.build_debug/lib/libcaffe.so: undefined reference to `cv::imread(cv::String const&, int)'
.build_debug/lib/libcaffe.so: undefined reference to `cv::imencode(cv::String const&, cv::_InputArray const&, std::vector<unsigned char, std::allocator<unsigned char> >&, std::vector<int, std::allocator<int> > const&)'
.build_debug/lib/libcaffe.so: undefined reference to `cv::imdecode(cv::/_InputArray const&, usrint)/bin/'ld:
warning: libcudart.so.5.5, needed by /usr/local/lib/libopencv_core.so, may conflict withcollect2: error: ld returned 1 exit status
libcudart.so.7.5
.build_debug/lib/libcaffe.so: undefined reference to `cv::imread(cv::String const&, int)'
.build_debug/lib/libcaffe.so: undefined reference to `cv::imencode(cv::String const&, cv::_InputArray const&, std::vector<unsigned char, std::allocator<unsigned char> >&, std::vector.<int, std::allocatorbuild_debug<int> /> constlib&)'/libcaffe.so
.build_debug/: lib/undefined referencelibcaffe.so: to make: `*** [.build_debug/tools/upgrade_net_proto_binary.bin] Error 1cvundefined: :referenceimread
( tocv:: `String cvconst&::imdecode, int(cv)'
.::_InputArraybuild_debug/ const&lib, int/)'
libcaffe.so: undefined reference to `cv::imencode(cv:collect2: error: ld returned 1 exit status
:String const&, cv::_InputArray const&, std::vector<unsigned char, std::allocator<unsigned char> >&, std::vector<int, std::allocator<int> > const&)'
.build_debug/lib/libcaffe.so: make: undefined reference*** [.build_debug/tools/caffe.bin] Error 1 to
`cv::imdecode(cv::_InputArray const&, int)'
::imread(cv::String const&, int)'
collect2: error: ld returned 1 exit status
.build_debug/lib/libcaffe.so: undefined reference to `cv::imencode(cv::String const&, cv::_InputArray const&, std::vector<unsigned char, std::allocator<unsigned char> >&, std::vector<int, std::allocator<int> > const&)'
.build_debug/lib/libcaffe.so: undefined reference to `cv::imdecode(cv::_InputArray const&, int)'
make: *** [.build_debug/tools/extract_features.bin] Error 1collect2: error: ld returned 1 exit status
make: *** [.build_debug/tools/compute_image_mean.bin] Error 1
.build_debug/lib/libcaffe.so: undefined reference to `cv::imread(cv::String const&, int)'
.build_debug/lib/libcaffe.so: undefined reference to `cv::imencode(cv::String const&, cv::_InputArray const&, std::vector<unsigned char, std::allocator<unsigned char> >&, std::vector<int, std::allocator<int> > const&)'
.build_debug/lib/libcaffe.so: undefined reference to `cv::imdecode(cv::_InputArray const&, int)'
collect2: error: ld returned 1 exit status
make: *** [.build_debug/tools/convert_imageset.bin] Error 1

Solution:

add opencv_imgcodecs in Makefile >>>>>>>>

LIBRARIES += opencv_core opencv_highgui opencv_imgproc

into

LIBRARIES += opencv_core opencv_highgui opencv_imgproc opencv_imgcodecs

then

1
2
make clean -j
make all -j

github issues: https://github.com/BVLC/caffe/issues/2348

Contents
  1. 1. Problem:
  2. 2. Solution:
|