ubuntu18.04(已经装了cuda10.0和opencv3.12)安装opencv2.4.11

由于在cmake时会出现CMake Error at cmake/OpenCVDetectCXXCompiler.cmake:85 (list)错误,因此替换OpenCVDetectCXXCompiler.cmake文件

cd /home/jerry/workspaces/DynaSlam_ws/opencv-2.4.11/opencv-2.4.11/cmake
mv OpenCVDetectCXXCompiler.cmake OpenCVDetectCXXCompiler.cmake.bak

然后下载我提供的OpenCVDetectCXXCompiler.cmake(链接: https://pan.baidu.com/s/1iJxOwUZTMxgPGp2bEfemhQ  密码: ion5)移动到改目录下

遇到错误1:CMake Error: The following variables are used in this project, but they are not found

参考这篇博客,原因是如果需要编译支持CUDA的OpenCV库时,如果编译计算机已经安装了CUDA驱动程序和OpenCV运行时,在利用CMake编译OpenCV时字段“WITH_CUDA”默认会被自动勾选上的。如果编译计算机未安装CUDA驱动程序和OpenCV运行时,CMake的字段“WITH_CUDA”默认就不会被自动勾选上。

解决办法

遇到错误2: fatal error: stdlib.h: No such file or directory

参考博文,因为如果改变gcc版本的话 编译过程中会提出不支持c++11出错,所以不改变gcc版本,仍然使用gcc7,然后参考博文中的方法一 更改相关文件中的#include_next为#include

遇到错误3:nvcc fatal : Unsupported gpu architecture 'compute_11'

When using cmake to do configurations, set the option CUDA_GENERATION to specific your GPU architecture. I ran across the same error and tried this to work out the problem.
this worked for me and shows a possible value for CUDA_GENERATION:
cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local -D CUDA_GENERATION=Kepler ..

遇到错误4:error: ‘CODEC_ID_AASC’ was not declared in this scope

cmake 时加上-D WITH_FFMPEG=OFF

遇到错误5:error: ‘NppiGraphcutState’ has not been declared

产生原因:

    cuda8.0较新,opencv-2.4.10较早,要编译通过需要修改源码:

解决方法:
将/data/opencv-2.4.11/modules/gpu/src/graphcuts.cpp

#if !defined (HAVE_CUDA) || defined (CUDA_DISABLER)   

修改为  

#if !defined (HAVE_CUDA) || defined (CUDA_DISABLER) || (CUDART_VERSION >= 8000) 

遇到错误6:the compiler can assume that the address of ‘annotate_img’ will never be N

修改 ./build/modules/contrib/CMakeFiles/opencv_contrib.dir/flags.make文件,删掉-Werror=address,然后重新make

 

这篇文章是为了运行DynaSlam做准备

 

  • 3
    点赞
  • 9
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值