当前位置:   article > 正文

视觉SLAM十四讲 报错 Could not find a configuration file for package “OpenCV“ that is compatible with reques_could not find a configuration file for package "o

could not find a configuration file for package "opencv" that is compatible

视觉SLAM十四讲 报错 Could not find a configuration file for package "OpenCV" that is compatible with requested version "4".

1. 问题

在编译高博的视觉SLAM十四讲ch8的optical_flow.cpp时,编译报错:

CMake Error at CMakeLists.txt:8 (find_package):
  Could not find a configuration file for package "OpenCV" that is compatible
  with requested version "4".

  The following configuration files were considered but not accepted:

    /usr/local/share/OpenCV/OpenCVConfig.cmake, version: 3.4.16

-- Configuring incomplete, errors occurred!
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9

2. 原因

在第八讲的这个程序里,CMakeLists.txt中编译find_package查找的是OpenCV4,而十四讲前面使用的opencv包括自己编译的都是opencv3版本,所以编译过程找不到相应的库文件以及链接,报错。

3. 解决方案

3.1 修改CMakeLists.txt

简单粗暴,虽然opencv版本不同,但是3到4大部分接口函数都是一样的,所以在CMakeLists.txt中将查找OpenCV4改为查找OpenCV3:

# find_package(OpenCV 4 REQUIRED)
find_package(OpenCV 3 REQUIRED)
  • 1
  • 2

然后就可以编译成功了。由于安装的Sophus版本或者G2o版本过高,还可能会出现fmt::v8的链接问题,解决方案在这里

3.2 编译OpenCV4版本

编译OpenCV以及多版本共存问题

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/Gausst松鼠会/article/detail/292878
推荐阅读
相关标签
  

闽ICP备14008679号