# 添加C++11标准支持
set(CMAKE_CXX_FLAGS "-std=c++11")
# 寻找opencv库
find_package(OpenCV REQUIRED)
# 添加头文件
include_directories(${OpenCV_INCLUDE_DIRS})
add_executable(test test.cpp)
# 链接opencv库
target_link_libraries(test ${OpenCV_LIBS})
即可编译通过
# 添加C++11标准支持
set(CMAKE_CXX_FLAGS "-std=c++11")
# 寻找opencv库
find_package(OpenCV REQUIRED)
# 添加头文件
include_directories(${OpenCV_INCLUDE_DIRS})
add_executable(test test.cpp)
# 链接opencv库
target_link_libraries(test ${OpenCV_LIBS})
即可编译通过