我正在尝试将程序链接到OpenCV库,这些库位于:/ usr / local / lib
所以在CMakeLists.txt中我把:
TARGET_LINK_LIBRARIES(myprogram
opencv_core
opencv_imgproc
opencv_highgui
opencv_imgproc
opencv_objdetect
)
继续建设,但如果我这样做:
ldd myprogram
我得到了:
...
libopencv_core.so.2.4 => not found
libopencv_imgproc.so.2.4 => not found
libopencv_highgui.so.2.4 => not found
libopencv_objdetect.so.2.4 => not found
所以为了能够运行它我必须每次将/ usr / local / lib添加到$ LD_LIBRARY_PATH
我做错了什么?
更新
我已将TARGET_LINK_LIBRARIES配置替换为此配置:
TARGET_LINK_LIBRARIES(myprogram ${OpenCV_LIBS})
现在它正确地链接了库..但是所有这些库!
答案 0 :(得分:0)
确保正确设置了环境变量,然后在CMakeList文件中使用这些行。
FIND_PACKAGE( OpenCV REQUIRED )
TARGET_LINK_LIBRARIES( myProject ${OpenCV_LIBS} )
答案 1 :(得分:0)
您需要配置动态库加载器以包含这些目录。添加/etc/ld.so.conf
文件的路径或在.conf
目录中创建/etc/ld.so.conf.d/
文件