使用命令
find /usr/ -name 'opencv.pc'
opencv.pc文件的地址,然后使用以下方式便可以正常连接opencv的动态库
cmake_minimum_required(VERSION 3.10)
project(video-preprocess-yolov5-test)
set(CMAKE_CXX_STANDARD 14)
set(OpenCV_DIR /usr/lib/x86_64-linux-gnu/pkgconfig)
find_package(OpenCV REQUIRED)
include_directories(/usr/include)
include_directories(${OpenCV_INCLUDE_DIRS})
MESSAGE(STATUS " version: ${OpenCV_VERSION}")
MESSAGE(STATUS " libraries: ${OpenCV_LIBS}")
MESSAGE(STATUS " include path: ${OpenCV_INCLUDE_DIRS}")
# include_directories(/home/mlu270/cpp-test/async-test/include)
link_directories(/usr/lib/x86_64-linux-gnu)
add_executable(${PROJECT_NAME} video-preprocess-yolov5-test.cpp)
target_link_libraries(${PROJECT_NAME} pthread ${OpenCV_LIBS})