Ubuntu18.04系统下Opencv2.4.11安装CMAKE错误记录

错误显示一个三个库没找到

1、 not found

fatal error: linux/videodev.h: 没有那个文件或目录
 #include
          ^~~~~~~~~~~~~~~~~~
compilation terminated.

解决方法:

安装libv4l-dev库

sudo apt-get install libv4l-dev

建立软映射连接

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

2、 not found

fatal error: sys/videoio.h: 没有那个文件或目录
 #include
          ^~~~~~~~~~~~~~~
compilation terminated.

这个不用管,不影响使用,参考:

https://blog.csdn.net/zhe_csdn/article/details/88679807

https://blog.csdn.net/Qin605/article/details/86609070

https://blog.csdn.net/xbs150/article/details/77840786#%E4%BE%8B1%E7%BC%BA%E5%B0%91videodevhlinuxvideodevh-not-found

解决方法:

让系统找到videoio.h即可

sudo mkdir /usr/include/sys/   #新建文件夹
sudo cp /usr/local/include/opencv2/videoio/videoio_c.h /usr/include/sys/
sudo ln -s /usr/include/sys/videoio_c.h /usr/include/sys/videoio.h

3、 not found

fatal error: ffmpeg/avformat.h: 没有那个文件或目录
 #include
          ^~~~~~~~~~~~~~~~~~~
compilation terminated.

这个错误是因为缺乏ffmpeg的库

解决方法:

安装ffmpeg

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

4、CUDA问题

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:
opencv_dep_CUDA_nppi_LIBRARY
    linked by target "opencv_test_core" in directory /home/ubuntu/Mydata/opencv-2.4.11/modules/core
    linked by target "opencv_test_core" in directory /home/ubuntu/Mydata/opencv-2.4.11/modules/core
    linked by target "opencv_core" in directory /home/ubuntu/Mydata/opencv-2.4.11/modules/core
    linked by target "opencv_core" in directory /home/ubuntu/Mydata/opencv-2.4.11/modules/core
    linked by target "opencv_perf_core" in directory /home/ubuntu/Mydata/opencv-2.4.11/modules/core

    .......

解决方法:https://blog.csdn.net/qq_15505637/article/details/79622968

5、Ubuntu 18.4不支持opencv-2.4.11自带的OpenCVDetectCXXCompiler.cmake

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


CMake Error at cmake/OpenCVDetectCXXCompiler.cmake:86 (list):
  list GET given empty list
Call Stack (most recent call first):
  CMakeLists.txt:89 (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:89 (include)

解决方法:

https://blog.csdn.net/u010003609/article/details/100086911

6、make出错

/usr/include/c++/7/cstdlib:75:15: fatal error: stdlib.h: 没有那个文件或目录
 #include_next
               ^~~~~~~~~~
compilation terminated.

cmake时加上参数-D ENABLE_PRECOMPILED_HEADERS=OFF

7、NVCC出错

nvcc fatal   : Unsupported gpu architecture 'compute_20'
CMake Error at cuda_compile_generated_matrix_operations.cu.o.cmake:208 (message):
  Error generating
  /home/ubuntu/Mydata/opencv-2.4.11/build/modules/core/CMakeFiles/cuda_compile.dir/__/dynamicuda/src/cuda/./cuda_compile_generated_matrix_operations.cu.o

解决方法:

cmake时加上参数-D CUDA_GENERATION=Kepler

你可能感兴趣的:(环境配置)