cmake cannot find -lopencv_dep_cudart

最近在使用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)

编译成功。
这里写图片描述


评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值