gpt4 book ai didi

使用编译的 OpenCV 版本进行 Cmake

转载 作者:行者123 更新时间:2023-11-30 19:38:37 33 4
gpt4 key购买 nike

我编译的是opencv-2.4.13版本,现在想使用cmake编译一个项目。

如果我这样做:

cmake_minimum_required(VERSION 3.5.1)
project(phase)
find_package(Opencv REQUIRED)
include_directories(INCLUDE_DIR include)
aux_source_directory(src SOURCE)
add_library(dct SHARED src/dct.c ${SOURCE}

我收到以下错误:

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

因此,我创建了一个名为 cmake-modules 的文件夹,并复制了编译后的 OpenCV 项目生成的 OpenCVConfig.cmake 文件。

然后:

cmake_minimum_required(VERSION 3.5.1)
project(phase)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/cmake-modules)
find_package(Opencv REQUIRED)
include_directories(INCLUDE_DIR include)
aux_source_directory(src SOURCE)
add_library(dct SHARED src/dct.c ${SOURCE})

但我仍然遇到同样的错误。

我应该如何包含 .cmake 文件来查找 OpenCV?

最佳答案

我通过以下方法解决了问题:

cmake_minimum_required(VERSION 3.5.1)
project(phase)
SET(OpenCV_INCLUDE_DIRS "/home/facu/opencv-2.4.13/include/opencv")
include_directories(INCLUDE_DIR include ${OpenCV_INCLUDE_DIRS})
set(OpenCV_LIB_DIR "/home/facu/opencv-2.4.13/release/lib")
link_directories(${OpenCV_LIB_DIR})
aux_source_directory(src SOURCE)
add_library(dct SHARED src/dct.c ${SOURCE})

关于使用编译的 OpenCV 版本进行 Cmake,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37766152/

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