本文介绍了在Ubuntu中基于OpenCV和ROS编译项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的项目上运行CMake(实际上是rosmake)时,我收到错误。我已经安装了OpenCV,但我得到以下错误:

I am receiving an error when running CMake (actually rosmake) on my project. I have already installed OpenCV, but I get the following error:

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

有人知道如何解决这个问题吗?

Does anyone know how to solve this?

推荐答案

显然,他找不到opencv链接对你的项目。您是否将它安装在/ usr或/ usr / local之外的其他位置?

Apparently, he could not find opencv to link against your project. Did you install it in somewhere else other than /usr or /usr/local?

如果是这样,您需要将路径添加到LD_LIBRARY_PATH变量等。
当您运行此系统时,系统会说什么?

If so, you need to add the path to LD_LIBRARY_PATH variable and so on.What does your system say when you run this?

pkg-config --cflags --libs opencv

如果你得到这样的东西,那么你的系统就可以了。

If you get something like this, then your system is ok.

-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将不会找到它:

but if you don't, your system is not able to find it and cmake will not find it either:

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

这篇关于在Ubuntu中基于OpenCV和ROS编译项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-27 15:53