cmake cannot find -lopencv

    xiaoxiao2021-04-17  55

    最近在使用v4l2获取视频。在编译的过程中,遇到了下面的问题,CMakeLists代码和报错程序截图如下:

    # cmake needs this line cmake_minimum_required(VERSION 2.8.4) # Define project name project(capturev4l2) # Find OpenCV find_package(OpenCV REQUIRED) # Add OpenCV headers location to your include paths include_directories(${OpenCV_INCLUDE_DIRS}) # Declare the executable target built from your sources set(SOURCE capturev4l2.c) add_executable(capturev4l2 ${SOURCE}) # Link your application with OpenCV libraries target_link_libraries(capturev4l2 ${OpenCV_LIBS})

    发现上面的错误提示有关于cuda,cmake cannot find -lopencv_dep_cudart。添加了cuda的CMakeLists依赖之后代码如下

    # cmake needs this line cmake_minimum_required(VERSION 2.8.4) # Define project name project(capturev4l2) # Find OpenCV find_package(OpenCV REQUIRED) find_package(CUDA) # Add OpenCV headers and cuda header location to your include paths include_directories(${OpenCV_INCLUDE_DIRS}) include_directories("/usr/local/cuda-8.0/include") # Declare the executable target built from your sources set(SOURCE capturev4l2.c) add_executable(capturev4l2 ${SOURCE}) # Link your application with OpenCV libraries target_link_libraries(capturev4l2 ${OpenCV_LIBS})

    编译

    $cmake .. $make

    最后在https://devtalk.nvidia.com/default/topic/970325/jetson-tx1/cmake-cannot-find-lopencv_dep_cudart/发现有人遇到了同样的问题。在CMakeLists加入下面这行代码

    set(CUDA_USE_STATIC_CUDA_RUNTIME OFF)

    编译成功。


    转载请注明原文地址: https://ju.6miu.com/read-673908.html

    最新回复(0)