c++ - CMake在Windows中找不到opencv
问题描述
我已经在 Windows 中安装了 OpenCV(来自源代码)
现在我想尝试一个测试,所以我有以下 CMakeLists.txt
cmake_minimum_required(VERSION 3.0.0)
project(opencvGPUtest_youtube VERSION 0.1.0)
include(CTest)
enable_testing()
find_package(OpenCV REQUIRED )
include_directories(( ${OpenCV_INCLUDE_DIRS}))
add_executable(opencvGPUtest_youtube main.cpp)
target_link_libraries(opencvGPUtest_youtube ${OpenCV_LIBS})
set(CPACK_PROJECT_NAME ${PROJECT_NAME})
set(CPACK_PROJECT_VERSION ${PROJECT_VERSION})
include(CPack)
但是,当我从我得到的构建文件夹中执行 cmake ..
CMake Error at CMakeLists.txt:13 (find_package):
By not providing "FindOpenCV.cmake" in CMAKE_MODULE_PATH this project has
asked CMake to find a package configuration file provided by "OpenCV", but
CMake did not find one.
Could not find a package configuration file provided by "OpenCV" with any
of the following names:
OpenCVConfig.cmake
opencv-config.cmake
Add the installation prefix of "OpenCV" to CMAKE_PREFIX_PATH or set
"OpenCV_DIR" to a directory containing one of the above files. If "OpenCV"
provides a separate development package or SDK, be sure it has been
installed.
我尝试编辑 CMakeLists.txt 文件以包含 Opencv 的目录,如
find_package(OpenCV REQUIRED PATH C:/Users/theuser/Path/To/MyOpenCVInstallation/build/install/x64/vc16/lib
或者
find_package(OpenCV REQUIRED PATH C:/Users/theuser/Path/To/MyOpenCVInstallation/build/win-install/x64/vc16/lib
但它仍然找不到 OpenCV
我也试过 -DOpenCV_DIR 选项,没有结果
如何让它识别 OpenCV?
编辑:
当我将 OpenCV_DIR 指定为 MyOpenCVInstallation/build/install/x64/vc16/lib 时,错误变为
CMake Error at C:/Program Files/CMake/share/cmake-3.20/Modules/FindPackageHandleStandardArgs.cmake:230 (message):
Could NOT find OpenCV (missing: PATH
C:/Users/user/Path/To/MyOpenCVInstallation/build/install/) (found
version "4.5.2")
Call Stack (most recent call first):
C:/Program Files/CMake/share/cmake-3.20/Modules/FindPackageHandleStandardArgs.cmake:594 (_FPHSA_FAILURE_MESSAGE)
C:/Users/user/path/to/MyOpenCVInstallation/build/install/x64/vc16/lib/OpenCVConfig.cmake:410 (find_package_handle_standard_args)
CMakeLists.txt:13 (find_package)
编辑2:
原来我不得不使用
find_package(OpenCV REQUIRED PATHS C:/Users/theuser/Path/To/MyOpenCVInstallation/build/install/x64/vc16/lib
有了这个,cmake似乎没问题。
但是通常此时(在 ubuntu 中)我运行make
但在 Windows 中我应该使用 VSCode 中的 CtrlF5
现在我得到了输出
-------------------------------------------------------------------
You may only use the C/C++ Extension for Visual Studio Code
with Visual Studio Code, Visual Studio or Visual Studio for Mac
software to help you develop and test your applications.
-------------------------------------------------------------------
Loaded 'C:\Users\aliag\DiskD\MyStudy\MyOpenCVInstallation\opencvgpu_test_youtube\build\Debug\opencvGPUtest_youtube.exe'. Symbols loaded.
Loaded 'C:\Windows\System32\ntdll.dll'.
Loaded 'C:\Windows\System32\kernel32.dll'.
Loaded 'C:\Windows\System32\KernelBase.dll'.
Loaded 'C:\Windows\System32\apphelp.dll'.
Loaded 'C:\Windows\System32\vcruntime140_1d.dll'.
Loaded 'C:\Windows\System32\vcruntime140d.dll'.
Loaded 'C:\Windows\System32\msvcp140d.dll'.
The program '[1112] opencvGPUtest_youtube.exe' has exited with code -1073741515 (0xc0000135).
所以我想这是一个不同的问题?
解决方案
推荐阅读
- react-native - 如何从反应原生下拉列表中删除选定的项目文本?
- flutter - Flutter/Dart - 加载未来时 CircularProgressIndicator 的透明背景?
- leaflet - 传单,基于折线生成连续坐标
- c# - 如何在 C# 中将 Xander 框架用于窗口窗体
- javascript - 函数返回数据以过滤和映射显示错误 React.js TypeError: Cannot read property 'val' of undefined
- sql-server - SQL Server:合并后的非聚集索引(插入/更新)
- python - 想自动生成Eclipse项目文件
- vba - 我可以在访问/excel 中使用宏/vba 来签署带有证书的 pdf 吗?
- sql - 有什么方法可以在 oracle sql 列默认值中实现,比如 excel 中的 today()?
- python - .py 到 .exe 具有很大的依赖关系