error adding symbols: DSO missing from command line(在CMakeList中的解决方法)

在Build时遇到一下问题

/usr/bin/ld: CMakeFiles/demo.dir/demo.cpp.o: undefined reference to symbol '_ZN2cv6resizeERKNS_11_InputArrayERKNS_12_OutputArrayENS_5Size_IiEEddi'

/usr/local/lib/libopencv_imgproc.so.2.4: error adding symbols: DSO missing from command line

collect2: error: ld returned 1 exit status

 

如果你是以CMakeList来管理项目,那么解决方法(以我的错误为例)如下:

1.打开CMakeList.txt

2.在CMakeList.txt中添加

//我缺少的是libopencv_imgproc.so.2.4这个链接库,我们只需要在CMakeList中定向链接这个库即可

set(LIB_OPENCV_IMGPROC_DIR /usr/local/lib)   //LIB_OPENCV_IMGPROC_DIR是变量名,可以随意写
add_library(libopencv_imgproc SHARED IMPORTED)
set_target_properties(libopencv_imgproc PROPERTIES IMPORTED_LOCATION ${LIB_OPENCV_IMGPROC_DIR}/libopencv_imgproc.so.2.4.9)

target_link_libraries(demo  libopencv_imgproc )//注意这条语句要放在add_executable的后面

 

你可能感兴趣的:(编译错误集合)