视觉SLAM十四讲 报错 Could not find a configuration file for package “OpenCV“ that is compatible with reques
Posted CSSDCC
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了视觉SLAM十四讲 报错 Could not find a configuration file for package “OpenCV“ that is compatible with reques相关的知识,希望对你有一定的参考价值。
视觉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!
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)
然后就可以编译成功了。由于安装的Sophus版本或者G2o版本过高,还可能会出现fmt::v8
的链接问题,解决方案在这里。
3.2 编译OpenCV4版本
以上是关于视觉SLAM十四讲 报错 Could not find a configuration file for package “OpenCV“ that is compatible with reques的主要内容,如果未能解决你的问题,请参考以下文章