Error when compile of caffe - undefined reference to symbol 'cv::String::deallocate()

1,136 views
Skip to first unread message

51flya

unread,
Feb 20, 2016, 4:58:33 AM2/20/16
to Caffe Users
Hi everyone, I am trying to compile caffe under Ubuntu 12.0.4 and Opencv 3.1
 When I enter [make all] errors as following has occurred.

CXX/LD -o .build_release/examples/cpp_classification/classification.bin
/usr/bin/ld: warning: libopencv_core.so.3.1, needed by /usr/local/lib/libopencv_imgcodecs.so, may conflict with libopencv_core.so.2.3
/usr/bin/ld: .build_release/examples/cpp_classification/classification.o: undefined reference to symbol 'cv::String::deallocate()'
/usr/bin/ld: note: 'cv::String::deallocate()' is defined in DSO /usr/local/lib/libopencv_core.so.3.1 so try adding it to the linker command line
/usr/local/lib/libopencv_core.so.3.1: could not read symbols: Invalid operation


I was not familiar with Makefile. Please help me.

Thank you!

Jan C Peters

unread,
Feb 22, 2016, 7:01:04 AM2/22/16
to Caffe Users
I am not sure, but I think caffe is meant to be built with OpenCV 2.4.x, which is the stock version in most distributions. Seems that in yours also, this is why you get all these conflicts and obscure errors.

To go that way, just remove everything OpenCV 3.x you have installed, install OpenCV 2.4.x by doing apt-get install libopencv-dev, and redo make all. You should not need to set specific include dirs or lib dirs.

Basically, do as http://caffe.berkeleyvision.org/install_apt.html says.

Jan

Paul

unread,
May 5, 2017, 5:13:48 PM5/5/17
to Caffe Users
Hi,

I got this error, too, when trying to compile caffe with OpenCV 3.2.0.  Here's how I fixed it:

Replace the following code in the Makefile:

ifeq ($(USE_OPENCV), 1)
    LIBRARIES += opencv_core opencv_highgui opencv_imgproc

    ifeq ($(OPENCV_VERSION), 3)
        LIBRARIES += opencv_imgcodecs
    endif

endif

With:

$(info $(USE_OPENCV))
$(info $(OPENCV_VERSION))
CV_VER_MAJOR := $(shell echo $(OPENCV_VERSION) | cut -f1 -d.)
$(info $(CV_VER_MAJOR))

ifeq ($(USE_OPENCV), 1)
    LIBRARIES += opencv_core opencv_highgui opencv_imgproc

    ifeq ($(CV_VER_MAJOR), 3)
        $(info adding opencv_imgcodecs library)
        LIBRARIES += opencv_imgcodecs
    endif

endif
$(info $(LIBRARIES))

Best,
Paul
Reply all
Reply to author
Forward
0 new messages