当前位置:   article > 正文

Linux下项目构建编译时OpenCV 找不到报错_cmake error at opencv_tutorial/cmakelists.txt:149

cmake error at opencv_tutorial/cmakelists.txt:149 (target_link_libraries): c

OpenCV 找不到或者系统版本不符合当前项目需求,报错如下:

cmake ..
# 输出如下:
CMake Error at example/CMakeLists.txt:2 (find_package):
  Could not find a configuration file for package "OpenCV" that is compatible
  with requested version "3.0.0".

  The following configuration files were considered but not accepted:

    /usr/local/lib64/cmake/opencv4/OpenCVConfig.cmake, version: 4.5.1



-- Configuring incomplete, errors occurred!

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
vim CMakeLists.txt 

# 添加如下:指定 你编译安装的 目录
set(OpenCV_DIR /build/opencv-3.4.13/build)
find_package(OpenCV REQUIRED)

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 正确输出效果如下:
cd build/
[root@f31df29c1509 build]# cmake ..
-- Found OpenCV: /build/opencv-3.4.13/build (found version "3.4.13") 
-- CMAKE_INSTALL_PREFIX = /usr/local
-- Found OpenCV: /build/opencv-3.4.13/build (found suitable version "3.4.13", minimum required is "3.0.0") found components: core imgcodecs imgproc highgui 
-- Found OpenMP_CXX: -fopenmp (found version "3.1") 
-- Found OpenMP: TRUE (found version "3.1")  
OPENMP FOUND
-- Configuring done
-- Generating done
-- Build files have been written to: /build/ocr/mobile-lpr-master/build

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12


cmake… 执行时 – 其它可能遇到的情况记录


比如:OpenCV_DIR 的路径设置为 安装路径 /usr/local 可能会遇到如下报错

9-0

原因是,OpenCV 路径设置不对

  • 设置为编译路径即可解决
vim ../CMakeLists.txt 


# 这个 文件中  OpenCV_DIR 的路径要设置正确,才能运行

set(OpenCV_DIR /home/moli/soft/sysOpenCV/opencv/build)
find_package(OpenCV REQUIRED)


  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9

9-1

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

闽ICP备14008679号