gpt4 book ai didi

opencv - 找不到模块 FindOpenCV.cmake(配置过程中出错)

转载 作者:太空宇宙 更新时间:2023-11-03 20:36:37 24 4
gpt4 key购买 nike

我用 C++ 为项目编写了一个 CMakeLists.txt,它使用了 OpenCV 库。当我尝试使用 cmake 创建项目时,我遇到了下一个配置问题:

CMake Error at CMakeLists.txt:15 (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

事实是我有一个环境变量用于我在 Visual Studio 中使用的路径,没有任何问题。如果我不包含 OpenCV,那么我可以毫无问题地配置和生成,但我需要解决这个问题。我不明白为什么 cmake 找不到 OpenCV 路径或如何修复它。

我还使用了此链接中提到的建议: FindOpenCV.cmake

有人遇到过这个问题吗?

最佳答案

您看到的错误是 CMake 找不到 FindOpenCV.cmake 文件,因为 cmake 不包含开箱即用的文件。因此,您需要找到一个并将其放在 cmake 可以找到的地方:

你可以找到一个good start here .如果您喜欢冒险,也可以自己编写。

然后将其添加到项目中的某处并调整 CMAKE_MODULE_PATH 以便 cmake 可以找到它。

例如,如果你有

CMakeLists.txt
cmake-modules/FindOpenCV.cmake

那么你应该做一个

set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/cmake-modules)

在执行 find_package(OpenCV) 之前在 CMakeLists.txt 文件中

关于opencv - 找不到模块 FindOpenCV.cmake(配置过程中出错),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8711109/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com