ubuntu 安装opencv2.4

已经有opencv3.2,但是同事的lib需要opencv2.4,否则报错undefined reference to `vtable for cv::_InputArray'

好吧。。。

下载opencv2.4.11的source之后,cmake发现报错。。。忍了一天,算了还是干它吧

找到帖子参考Ubuntu18.04系统下Opencv2.4.11安装CMAKE错误记录_博博有个大大大的Dream的博客-CSDN博客_opencv2.4.11 cmke失敗,不错,但是还有点修改,干脆我也记录一下:

第一个error:

not found

解决方法:

安装libv4l-dev,建链接

sudo apt-get install libv4l-dev

sudo ln -s /usr/include/libv4l1-videodev.h /usr/include/linux/videodev.h

第二个error:

sys/videoio.h> not found

touch /usr/include/sys/videoio.h

第三个error:

 not found

sudo apt install ffmpeg
sudo mkdir /usr/include/ffmpeg
sudo ln -s /usr/include/x86_64-linux-gnu/libavformat/avformat.h /usr/include/ffmpeg/avformat.h
sudo ln -s /usr/include/x86_64-linux-gnu/libavformat/avio.h /usr/include/ffmpeg/avio.h

第四个error:

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)

首先按原文链接修改:

Window CMAKE 编译opencv3.4.1(CUDA9.1)遇到错误 linked by target "opencv_cudev" in directory_cvml的博客-CSDN博客

但是,这里面注意:

1. 原链接里面的方法有不适用的地方,需要修改:

我cuda是11,按原链接修改后报错CUDA_nppicom_LIBRARY又找不到了,索性将刚才在FindCUDA.cmake里面加的nppicom相关的又删了就好了。

2. 我的是新显卡,所以自己去查架构和bin号,我在官网查的,

Compare GeForce Gaming RTX 30 Series Laptops | NVIDIA

还有别的方法:Ubuntu18 查看CUDA的CUDA_ARCH_BIN_元宇宙MetaAI的博客-CSDN博客_cuda_arch_bin

然后,就在cmake目录里面的OpenCVDetectCUDA.cmake文件加入这个就行了

elseif(CUDA_GENERATION STREQUAL "Ampere")
    set(__cuda_arch_bin "8.6")

这一段我没验证,就是按原链接指导改了这段,后来也没报错。

3. 链接里面的第5步我没做。

第五个error:

CMake Error at cmake/OpenCVDetectCXXCompiler.cmake:85 (list):
  list GET given empty list
Call Stack (most recent call first):
  CMakeLists.txt:84 (include)


CMake Error at cmake/OpenCVDetectCXXCompiler.cmake:86 (list):
  list GET given empty list
Call Stack (most recent call first):
  CMakeLists.txt:84 (include)


CMake Error at cmake/OpenCVDetectCXXCompiler.cmake:89 (math):
  math cannot parse the expression: "*100 + ": syntax error, unexpected
  exp_TIMES, expecting exp_PLUS or exp_MINUS or exp_OPENPARENT or exp_NUMBER
  (1)
Call Stack (most recent call first):
  CMakeLists.txt:84 (include)

按这个修改一下:

ubuntu18.04安装opencv2.4.10问题记录 – SigmaPoet

在cmake目录下,将 OpenCVDetectCXXCompiler.cmake里面,修改第67行"-dumpversion" 为 "-dumpfullversion"

 


好了,然后cmake

cmake -D ENABLE_PRECOMPILED_HEADERS=OFF ..

就能顺利看到makefile了


但是,还是报错了,

nvcc fatal : Unsupported gpu architecture 'compute_11'

nvcc fatal : Unsupported gpu architecture 'compute_11'_wishchin的博客-CSDN博客

修改后,又报错

 nvcc fatal : Unsupported gpu architecture 'compute_30‘

放弃了,

cmake -D ENABLE_PRECOMPILED_HEADERS=OFF -D WITH_FFMPEG=OFF  -D WITH_CUDA=OFF ..

安装opencv编译过程中几个不常见的小错误_Steve_Logan的博客-CSDN博客_error: ‘codec_id_h264’ was not declared in this sc

这样就能make成功了。

你可能感兴趣的:(ubuntu,linux,运维)