生成OpenCV时CMake错误-CMakeLists不匹配 [英] CMake error when building OpenCV - CMakeLists not match

查看:1871
本文介绍了生成OpenCV时CMake错误-CMakeLists不匹配的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试在Raspberry Pi 2B上构建OpenCV 3.1.0.不幸的是,当我尝试:

I tried to build OpenCV 3.1.0 on my Raspberry Pi 2B. Unfortunetly, when I trying:

cmake -D CMAKE_BUILD_TYPE =发布\ -D CMAKE_INSTALL_PREFIX =/usr/local \ -D INSTALL_C_EXAMPLES = OFF \ -D INSTALL_PYTHON_EXAMPLES = OFF/home/pi/Downloads/opencv-3.1.0

cmake -D CMAKE_BUILD_TYPE=RELEASE \ -D CMAKE_INSTALL_PREFIX=/usr/local \ -D INSTALL_C_EXAMPLES=OFF \ -D INSTALL_PYTHON_EXAMPLES=OFF /home/pi/Downloads/opencv-3.1.0

它给了我一个错误:(:

It gave me a error :( :

CMake错误:源"/home/pi/Downloads/opencv-3.1.0/CMakeLists.txt"与源"/home/pi/Downloads/opencv-3.1.0/modules/CMakeLists.txt"不匹配"用于生成缓存.使用其他源目录重新运行cmake.

CMake Error: The source "/home/pi/Downloads/opencv-3.1.0/CMakeLists.txt" does not match the source "/home/pi/Downloads/opencv-3.1.0/modules/CMakeLists.txt" used to generate cache. Re-run cmake with a different source directory.

我想将OpenCV与已经安装的C ++和Code :: Bocks一起使用. 我在互联网上找不到任何解决方案,因此,如果smb帮助我,我将非常高兴. :)忘了说我使用Raspbian Jezzy.

I want to use OpenCV with C++ and Code::Bocks, which I have already installed. I can't found any solution on internet, so I will be very happy if smb help me. :) Forgot to say I using Raspbian Jezzy.

推荐答案

首先,我希望您在单独的目录中的源代码 outside 外运行CMake.真的不建议不这样做

First, I hope you do run CMake outside your sources, in a separate directory. Not doing that is really not recommended

要了解错误消息,您必须了解CMake的工作原理.

To understand the error message you have to know a little bit on how CMake works.

基本上,当您运行

cd /path/to/opencv
mkdir build
cd build
cmake ..

CMake在构建目录中生成一个缓存(这是一个名为CMakeCache.txt的简单文件).该文件包含一些信息,例如:

CMake generates a cache in the build dir (It's a simple file named CMakeCache.txt). This file contains some information like:

  • 源/path/to/opencv的路径
  • 构建目录的路径/path/to/opencv/build
  • 使用的CMake生成器(忍者,Unix Makefile ...)

如果您重新运行CMake并更改了其中一个值(通过使用不同的参数重新运行cmake,设置其他Generotor或移动文件),CMake会发出此类消息.

If you ever re-run CMake and change one of these values, (by re-running cmake with different arguments, setting an other generotor or moving files), CMake will complain with this kind of message.

然后一个好的解决方案是删除CMakeCache甚至整个构建目录,以确保安全.

A good solution is then to delete the CMakeCache, or even the whole build dir to be safe.

这篇关于生成OpenCV时CMake错误-CMakeLists不匹配的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆