ubuntu16.04下出现Found package configuration file:/usr/local/share/OpenCV/OpenCVConfig.cmake but it set

ubuntu16.04下用cmake编译opencv程序出现各种奇葩错误,记录一下

错误内容如下

Found package configuration file:/usr/local/share/OpenCV/OpenCVConfig.cmake but it set OpenCV_FOUND to FALSE so package "OpenCV" is considered to be NOT FOUND。

搜了博客有的博主重新编译opencv或者用其他方法

总结一下,首先需要将opencv的路径设置一下

set(OpenCV_DIR  /home/wzf/opencv-3.1.0/build)

再将OpenCV_FOUND 设置为1,也就是True

set( OpenCV_FOUND 1 )

重新编译,编译成功

我的CMakeList.txt文件如下

cmake_minimum_required( VERSION  3.14)
project( joinMap )

set(CMAKE_CXX_STANDARD 11)

set(OpenCV_DIR  /home/wzf/opencv-3.1.0/build)
set( OpenCV_FOUND 1 )
# opencv 
find_package( OpenCV REQUIRED)

include_directories( ${OpenCV_INCLUDE_DIRS} )

# eigen
include_directories( "/usr/include/eigen3/" )

# pcl
find_package( PCL REQUIRED COMPONENT common io )
list(REMOVE_ITEM PCL_LIBRARIES "vtkproj4")
include_directories( ${PCL_INCLUDE_DIRS} )
add_definitions( ${PCL_DEFINITIONS} )

add_executable( joinMap joinMap.cpp )
target_link_libraries(joinMap ${OpenCV_LIBS} ${PCL_LIBRARIES})

 

你可能感兴趣的:(解决错误)