cmake 在 opencv c++ 项目中不起作用

cmake is not working in opencv c++ project(cmake 在 opencv c++ 项目中不起作用)

本文介绍了cmake 在 opencv c++ 项目中不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要你的帮助!我在这个链接中有这个 C++ 代码

[链接] https://github.com/royshil/FoodcamClassifier

而且我两天以来一直在尝试编译它,但我失败了他们说我必须使用 cmake ,我试过GUI 版本,它给了我与 cmake 本身相关的错误.所以我拿了 cpp 和头文件并创建了一个新项目,但我现在有 100 个与 opencv 库相关的错误,我向上帝发誓我确定我的项目中包含文件夹和它的库!不知道怎么回事!

有什么想法吗?

错误如下:

<前>'CMake 错误:无法打开缓存文件进行保存.C:/Program Files/CMake 2.8/bin/CMakeCache.txtCMakeLists.txt:4 (FIND_PACKAGE) 处的 CMake 错误:找不到模块 FindOpenCV.cmake 或包的配置文件开放简历.调整 CMAKE_MODULE_PATH 以找到 FindOpenCV.cmake 或将 OpenCV_DIR 设置为包含 OpenCV 的 CMake 配置文件的目录.该文件将具有以下名称之一:OpenCVConfig.cmakeopencv-config.cmakeOpenCV_DIR-NOTFOUND配置不完整,出现错误!CMake 错误:无法打开缓存文件进行保存.C:/Program Files/CMake 2.8/bin/CMakeCache.txtCMake 错误::系统错误:权限被拒绝CMake 错误::系统错误:权限被拒绝 '

解决方案

您可能需要在 CMakeLists.txt 之前 中添加以下代码段行 FIND_PACKAGE(OpenCV Required) (在我的情况下):

SET("OpenCV_DIR" "PATH/TO/CMake/build")

在我的安装中它解决了问题,因为提到的文件位于构建文件夹中.

I need your help ! I have this C++ code in this link

[link] https://github.com/royshil/FoodcamClassifier

and I've been trying since two days to compaile it , and I've failed they say that I have to use cmake , I've tried the "GUI version and it gave me errors realted to the cmake itself . so I took the cpp and header files and made a new project but I have now 100 errors related to the opencv library and I swear to god I'm sure of the include folders and the libs of it in my project ! don't know what's the matter with it !

any idea ?

Here's the errors :

'CMake Error: Unable to open cache file for save. C:/Program Files/CMake 2.8/bin/CMakeCache.txt
CMake Error at CMakeLists.txt:4 (FIND_PACKAGE):
  Could not find module FindOpenCV.cmake or a configuration file for package
  OpenCV.

  Adjust CMAKE_MODULE_PATH to find FindOpenCV.cmake or set OpenCV_DIR to the
  directory containing a CMake configuration file for OpenCV.  The file will
  have one of the following names:

    OpenCVConfig.cmake
    opencv-config.cmake



OpenCV_DIR-NOTFOUND
Configuring incomplete, errors occurred!
CMake Error: Unable to open cache file for save. C:/Program Files/CMake 2.8/bin/CMakeCache.txt
CMake Error: : System Error: Permission denied
CMake Error: : System Error: Permission denied '

解决方案

You're probably gonna have to add the following piece of code in the CMakeLists.txt before the line FIND_PACKAGE(OpenCV Required) (in my case):

SET("OpenCV_DIR" "PATH/TO/CMake/build")

In my installation it solved the problem since the mentioned files are located in the build folder.

这篇关于cmake 在 opencv c++ 项目中不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本文标题为:cmake 在 opencv c++ 项目中不起作用

基础教程推荐