OpenCV编译错误:/usr/local/lib/opencv_core.so.3.1:error adding symols: DSO missing from command line

今天编译一个c++文件 用到opencv,编译出错,通过百度 解决了,

错误代码:

------------------------
root@caffe:~/thrid_week# g++ -o test_mnist test_mnist.cpp -lopencv_dnn -lopencv_highgui -lopencv_imgcodecs -lopencv_imgproc -lstdc++ -lopencv_core
/usr/bin/ld: warning: libopencv_imgproc.so.3.1, needed by //usr/local/lib/libopencv_dnn.so, may conflict with libopencv_imgproc.so.2.4
/usr/bin/ld: warning: libopencv_core.so.3.1, needed by //usr/local/lib/libopencv_dnn.so, may conflict with libopencv_core.so.2.4
/usr/bin/ld: /tmp/cczT82RA.o: undefined reference to symbol '_ZN2cv6String10deallocateEv'
//usr/local/lib/libopencv_core.so.3.1: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status

解决方式:
在编译的时候 加上opencv lib的地址 我的是 /usr/local/lib,所以如下编译

root@caffe:~/thrid_week# g++ -L /usr/local/lib -o test_mnist test_mnist.cpp -lopencv_dnn -lopencv_highgui -lopencv_imgcodecs -lopencv_imgproc -lstdc++ -lopencv_core

感谢解决这个问题的大神,附上原来的解决的网站连接:点击此处

你可能感兴趣的:(Ubuntu,opencv)