在我的项目上运行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

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

最佳答案

显然,他找不到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

10-08 06:53