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库。
下一篇: 特效文字代码[转]