我在项目中运行CMake(实际上是rosmake)时收到错误。我已经安装了OpenCV,但是我收到以下错误:
Linking CXX shared library ../lib/libCornerHelper.so
/usr/bin/ld: cannot find -lopencv_contrib
/usr/bin/ld: cannot find -lopencv_legacy
/usr/bin/ld: cannot find -lopencv_stitching
/usr/bin/ld: cannot find -lopencv_gpu
/usr/bin/ld: cannot find -lopencv_objdetect
/usr/bin/ld: cannot find -lopencv_calib3d
/usr/bin/ld: cannot find -lopencv_features2d
/usr/bin/ld: cannot find -lopencv_video
/usr/bin/ld: cannot find -lopencv_highgui
/usr/bin/ld: cannot find -lopencv_ml
/usr/bin/ld: cannot find -lopencv_imgproc
/usr/bin/ld: cannot find -lopencv_flann
/usr/bin/ld: cannot find -lopencv_core
collect2: ld returned 1 exit status
make[3]: *** [../lib/libCornerHelper.so] Error 1
有谁知道如何解决这个问题?
答案 0 :(得分:2)
显然,他找不到opencv来链接你的项目。您是否在/ usr或/ usr / local以外的其他地方安装了它?
如果是这样,您需要添加LD_LIBRARY_PATH变量的路径,依此类推。 你运行它时系统会说什么?
pkg-config --cflags --libs opencv
如果你得到这样的东西,那么你的系统就可以了。
-I/opt/opencv/include/opencv -I/opt/opencv/include -L/opt/opencv/lib -lopencv_core -lopencv_imgproc -lopencv_highgui -lopencv_ml -lopencv_video -lopencv_features2d -lopencv_calib3d -lopencv_objdetect -lopencv_contrib -lopencv_legacy -lopencv_flann
但如果你不这样做,你的系统将无法找到它,cmake也找不到它:
Package opencv was not found in the pkg-config search path. Perhaps you should add the directory containing `opencv.pc' to the PKG_CONFIG_PATH environment variable No package 'opencv' found
答案 1 :(得分:0)
如果您在ROS中使用OpenCV,如果您在manifest.xml文件中声明了对opencv2的依赖,则应自动选择相应的链接标记和路径。
如果您仍有问题,建议您搜索ROS Answers,如果找不到任何问题,请在那里提问。这是官方的ROS支持论坛,可能会比StackOverflow更好地解决ROS特定问题。