opencv 2.4.9编译踩坑笔记

为了跑GSLAM,一直遇到opencv版本的问题,本机之前是4.1.0,作者回答用的版本是opencv2.4.9,没办法,再装一个。

 

最终我的CMAKE指令:

cmake -D CMAKE_INSTALL_PREFIX=/usr/local/opencv/2.4.9 -D WITH_TBB=ON -D WITH_OPENMP=ON -D WITH_IPP=ON -D BUILD_PERF_TESTS=OFF -D BUILD_TESTS=OFF -D ENABLE_PRECOMPILED_HEADERS=OFF -DCMAKE_C_COMPILER=gcc-6 -DCMAKE_CXX_COMPILER=g++-6 -D WITH_FFMPEG=OFF -D WITH_CUDA=OFF ..

1.CUDA_nppi_LIBRARY

CMake Error: The following variables are used in this project, but they are set to NOTFOUND.
Please set them or make sure they are set and tested correctly in the CMake files:
CUDA_nppi_LIBRARY (ADVANCED)

FIX:

https://stackoverflow.com/questions/46584000/cmake-error-variables-are-set-to-notfound

2.缺少xxx.h文件

缺少xxx.h文件安装方法——————到/usr/include/目录下面查找类似的文件
下面是两个例子(前提是安装好相关依赖包,根据缺少的.h文件寻找需要的包)

例1:缺少videodev.h————linux/videodev.h not found

例2:缺少videoio.h————sys/videoio.h not found

FIX:https://blog.csdn.net/xbs150/article/details/77840786

3.GCC 版本

[  3%] Building NVCC (Device) object src/thundersvm/CMakeFiles/thundersvm.dir/kernel/thundersvm_generated_smo_kernel.cu.o
In file included from /usr/local/cuda/include/host_config.h:50:0,
                 from /usr/local/cuda/include/cuda_runtime.h:78,
                 from <command-line>:0:
/usr/local/cuda/include/crt/host_config.h:121:2: error: #error -- unsupported GNU version! gcc versions later than 6 are not supported!
 #error -- unsupported GNU version! gcc versions later than 6 are not supported!
  ^~~~~

FIX:

CMAKE 指定GCC版本

-D CMAKE_C_COMPILER=gcc-6 -D CMAKE_CXX_COMPILER=g++-6

4.ffmpeg

In file included from /home/kunb/slam_code/opencv-2.4.9/modules/highgui/src/cap_ffmpeg_impl.hpp:60:0,
                 from /home/kunb/slam_code/opencv-2.4.9/modules/highgui/src/cap_ffmpeg.cpp:45:
/home/kunb/slam_code/opencv-2.4.9/modules/highgui/src/ffmpeg_codecs.hpp:104:7: error: ‘CODEC_ID_H264’ was not declared in this scope
     { CODEC_ID_H264, MKTAG('H', '2', '6', '4') },
       ^~~~~~~~~~~~~
/home/kunb/slam_code/opencv-2.4.9/modules/highgui/src/ffmpeg_codecs.hpp:105:7: error: ‘CODEC_ID_H264’ was not declared in this scope
     { CODEC_ID_H264, MKTAG('h', '2', '6', '4') },
       ^~~~~~~~~~~~~
/home/kunb/slam_code/opencv-2.4.9/modules/highgui/src/ffmpeg_codecs.hpp:106:7: error: ‘CODEC_ID_H264’ was not declared in this scope
     { CODEC_ID_H264, MKTAG('X', '2', '6', '4') },
(后面太长,不贴了)

FIX:

CMAKE直接关闭ffmpeg

 -D WITH_FFMPEG=OFF 

关闭此项不会对提取视频文件产生影响,具体见https://github.com/opencv/opencv/pull/4107

5.cuda冲突

本来想用cuda的,但是这迫不得已,时间有限,还是关了吧

modules/gpu/CMakeFiles/opencv_gpu.dir/build.make:1604: recipe for target 'modules/gpu/CMakeFiles/cuda_compile.dir/src/nvidia/core/cuda_compile_generated_NCVPyramid.cu.o' failed
make[2]: *** [modules/gpu/CMakeFiles/cuda_compile.dir/src/nvidia/core/cuda_compile_generated_NCVPyramid.cu.o] Error 1
make[2]: 离开目录“/home/kunb/slam_code/opencv-2.4.9/build”
CMakeFiles/Makefile2:1477: recipe for target 'modules/gpu/CMakeFiles/opencv_gpu.dir/all' failed
make[1]: *** [modules/gpu/CMakeFiles/opencv_gpu.dir/all] Error 2
make[1]: 离开目录“/home/kunb/slam_code/opencv-2.4.9/build”
Makefile:151: recipe for target 'all' failed
make: *** [all] Error 2

 FIX:

-D WITH_CUDA=OFF

6.chamfermatching

cc1plus: some warnings being treated as errors modules/contrib/CMakeFiles/opencv_contrib.dir/build.make:158: recipe for target 'modules/contrib/CMakeFiles/opencv_contrib.dir/src/chamfermatching.cpp.o' failed

这个问题在https://github.com/opencv/opencv/issues/6517中,提问者的解决方法是更改到2.4.12.2,他参考的是https://github.com/opencv/opencv/pull/5674

不过都到这里了,不想再重新下代码什么的走一遍,我直接替换了chamfermatching.cpp文件,然后继续编译

https://github.com/opencv/opencv/blob/eebd4cad665f4f1270ca58bb13e9708e130f9b30/modules/contrib/src/chamfermatching.cpp

FIX:

从上面网址获取chamfermatching.cpp,替换<opencv2.4.9dir>/modules/contrib/src/chamfermatching.cpp

  • 8
    点赞
  • 26
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 2
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

KunB在学习

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值