opencv安装时找不到cuda的错误解决方式

编译环境 ubuntu1604+opencv3.2+cuda8.0

编译opencv时碰到如下是错误

Scanning dependencies of target example_gpu_alpha_comp
CMakeFiles/example_gpu_driver_api_multi.dir/driver_api_multi.cpp.o: In function `destroyContexts()':
driver_api_multi.cpp:(.text._Z15destroyContextsv+0xc): undefined reference to `cuCtxDestroy_v2'
driver_api_multi.cpp:(.text._Z15destroyContextsv+0x1c): undefined reference to `cuCtxDestroy_v2'
CMakeFiles/example_gpu_driver_api_multi.dir/driver_api_multi.cpp.o: In function `Worker::operator()(int) const':
driver_api_multi.cpp:(.text._ZNK6WorkerclEi+0x37): undefined reference to `cuCtxPushCurrent_v2'
driver_api_multi.cpp:(.text._ZNK6WorkerclEi+0x893): undefined reference to `cuCtxPopCurrent_v2'
CMakeFiles/example_gpu_driver_api_multi.dir/driver_api_multi.cpp.o: In function `main':
driver_api_multi.cpp:(.text.startup.main+0x11c): undefined reference to `cuInit'
driver_api_multi.cpp:(.text.startup.main+0x133): undefined reference to `cuDeviceGet'
driver_api_multi.cpp:(.text.startup.main+0x14d): undefined reference to `cuCtxCreate_v2'
driver_api_multi.cpp:(.text.startup.main+0x15d): undefined reference to `cuCtxPopCurrent_v2'
driver_api_multi.cpp:(.text.startup.main+0x172): undefined reference to `cuDeviceGet'
driver_api_multi.cpp:(.text.startup.main+0x18c): undefined reference to `cuCtxCreate_v2'
driver_api_multi.cpp:(.text.startup.main+0x19c): undefined reference to `cuCtxPopCurrent_v2'
collect2: error: ld returned 1 exit status
samples/gpu/CMakeFiles/example_gpu_driver_api_multi.dir/build.make:125: recipe for target 'bin/example_gpu_driver_api_multi' failed
make[2]: *** [bin/example_gpu_driver_api_multi] Error 1
CMakeFiles/Makefile2:39358: recipe for target 'samples/gpu/CMakeFiles/example_gpu_driver_api_multi.dir/all' failed
make[1]: *** [samples/gpu/CMakeFiles/example_gpu_driver_api_multi.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs....


cmake命令参数如下

cmake -D CMAKE_BUILD_TYPE=RELEASE       -D CMAKE_INSTALL_PREFIX=/usr/local       -D INSTALL_C_EXAMPLES=ON       -D INSTALL_PYTHON_EXAMPLES=ON       -D WITH_TBB=ON       -D WITH_V4L=ON       -D WITH_QT=ON       -D WITH_OPENGL=ON       -D OPENCV_EXTRA_MODULES_PATH=../../opencv_contrib/modules       -D BUILD_EXAMPLES=ON -D CMAKE_LIBRARY_PATH=/usr/local/cuda-8.0/lib64/stubs -D CUDA_CUDA_LIBRARY=/usr/local/cuda-8.0/lib64/stubs/libcuda.so ..


原因是找不到cuda库,解决方式如下(红色为新添加)

https://github.com/opencv/opencv/pull/10954/commits/5c66ce7f29976bc6307b5a7191f040fa7337e437

https://github.com/opencv/opencv/pull/10954/files

3  samples/gpu/CMakeLists.txt
@@ -50,6 +50,9 @@ endif()
 foreach(sample_filename ${all_samples})
   ocv_define_sample(tgt ${sample_filename} gpu)
   ocv_target_link_libraries(${tgt} ${OPENCV_LINKER_LIBS} ${OPENCV_CUDA_SAMPLES_REQUIRED_DEPS})
  if(HAVE_CUDA AND NOT ANDROID)
    ocv_target_link_libraries(${tgt} ${CUDA_CUDA_LIBRARY})
  endif()

   if(HAVE_opencv_xfeatures2d)
     ocv_target_link_libraries(${tgt} opencv_xfeatures2d)
   endif()
  • 4
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值