CMake找不到庫(如opencv)的解決辦法


一、問題詳情
在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庫。


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM