成为上进青年 2023-05-12 18:04 采纳率: 83.3%
浏览 78

使用Cmake编译opencv时遇到问题

我是要在Windows 下使用Cmake 编译opencv,然后导入QT进行使用。能帮我看一下这是哪里错了吗,都是按照博主的教程来的,还是不行,opencv contrib 也下了。

img


下面是错误提醒


```c
CMake Deprecation Warning at CMakeLists.txt:22 (cmake_minimum_required):
  Compatibility with CMake < 2.8.12 will be removed from a future version of
  CMake.

  Update the VERSION argument <min> value or use a ...<max> suffix to tell
  CMake that the project does not need compatibility with older versions.


CMake Deprecation Warning at CMakeLists.txt:72 (cmake_policy):
  The OLD behavior for policy CMP0020 will be removed from a future version
  of CMake.

  The cmake-policies(7) manual explains that the OLD behaviors of all
  policies are deprecated and that a policy should be set to OLD only under
  specific short-term circumstances.  Projects should be ported to the NEW
  behavior and not rely on setting a policy to OLD.


CMake Deprecation Warning at CMakeLists.txt:76 (cmake_policy):
  The OLD behavior for policy CMP0022 will be removed from a future version
  of CMake.

  The cmake-policies(7) manual explains that the OLD behaviors of all
  policies are deprecated and that a policy should be set to OLD only under
  specific short-term circumstances.  Projects should be ported to the NEW
  behavior and not rely on setting a policy to OLD.


CMake Deprecation Warning at CMakeLists.txt:81 (cmake_policy):
  The OLD behavior for policy CMP0026 will be removed from a future version
  of CMake.

  The cmake-policies(7) manual explains that the OLD behaviors of all
  policies are deprecated and that a policy should be set to OLD only under
  specific short-term circumstances.  Projects should be ported to the NEW
  behavior and not rely on setting a policy to OLD.


Can't detect runtime and/or arch
CMake Error at cmake/OpenCVCompilerOptions.cmake:21 (else):
  Flow control statements are not properly nested.
Call Stack (most recent call first):
  CMakeLists.txt:495 (include)


Configuring incomplete, errors occurred!


  • 写回答

4条回答 默认 最新

  • 阿里嘎多学长 2023-05-12 21:33
    关注

    以下内容由CHATGPT及阿里嘎多学长共同生成、有用望采纳:

    这个问题可能是由于缺少必要的依赖项或配置错误引起的。建议重新检查CMake配置是否正确,并确保已正确设置必要的环境变量和路径。

    另外,您可以尝试使用CMake的GUI界面来配置和生成项目,以便更方便地调试和调整配置选项。

    以下是可能有用的一些示例代码:

    cmake_minimum_required(VERSION 3.0)
    project(opencv_example)
    find_package(OpenCV REQUIRED)
    include_directories(${OpenCV_INCLUDE_DIRS})
    add_executable(example example.cpp)
    target_link_libraries(example ${OpenCV_LIBS})
    

    在这个示例中,我们使用CMake来构建一个名为“opencv_example”的项目,并使用OpenCV作为依赖项。我们首先查找OpenCV,并将其包含目录添加到项目中。我们然后创建一个可执行文件“example”,并将其链接到OpenCV库。

    希望这些信息有助于解决您的问题!

    评论

报告相同问题?

问题事件

  • 创建了问题 5月12日

悬赏问题

  • ¥15 Workbench中材料库无法更新,如何解决?
  • ¥20 如何推断此服务器配置
  • ¥15 关于github的项目怎么在pycharm上面运行
  • ¥15 内存地址视频流转RTMP
  • ¥100 有偿,谁有移远的EC200S固件和最新的Qflsh工具。
  • ¥15 有没有整苹果智能分拣线上图像数据
  • ¥20 有没有人会这个东西的
  • ¥15 cfx考虑调整“enforce system memory limit”参数的设置
  • ¥30 航迹分离,航迹增强,误差分析
  • ¥15 Chrome Manifest扩展引用Ajax-hook库拦截请求失败