一、問題詳情
在ubuntu中使用CMake編譯鏈接opencv庫的程序時FIND_PACKAGE(OpenCV REQUIRED)報錯,找不到opencv,信息如下:
Found OpenCV Windows Pack but it has no binaries compatible with your
configuration.
You should manually point CMake variable OpenCV_DIR to your build of OpenCV
library.
Call Stack (most recent call first):
CMakeLists.txt:4 (find_package)
CMake Error at CMakeLists.txt:4 (find_package):
Found package configuration file:
/home/wj/opencv/cmake/OpenCVConfig.cmake
but it set OpenCV_FOUND to FALSE so package "OpenCV" is considered to be
NOT FOUND.
-- Configuring incomplete, errors occurred!
二、解決方法
經過查閱資料病各種嘗試,現已解決。主要問題在於庫路徑問題,應該在CMakeLists.txx中設置opencv路徑指向build文件夾。
set(OpenCV_DIR /path/to/opencv/build)
find_package(OpenCV REQUIRED)
這樣才能正確的找到opencv庫。