Ubuntu20.04+Cuda 11.2安装OpenCV2.4.8 问题记录

cmake 过程

cmake 命令:

cmake -DWITH_QT=ON -DWITH_OPENGL=ON -DFORCE_VTK=ON -DWITH_TBB=ON -DWITH_GDAL=ON -D CUDA_nppicom_LIBRARY=/usr/local/cuda/lib64/libnppicc.so -DWITH_XINE=ON -DBUILD_EXAMPLES=ON -DENABLE_PRECOMPILED_HEADERS=OFF -DCMAKE_BUILD_TYPE=RELEASE -D CUDA_GENERATION=Kepler -D WITH_FFMPEG=OFF -Wno-dev -Wno-error=deprecated-declarations -Wno-deprecated-declarations -Wno-deprecated -Wno-deprecated-copy -Wno-class-memaccess .. 
  1. videodev.hvideodev2.hvideoio.h 找不到

问题:

-- Looking for linux/videodev.h                                              
-- Looking for linux/videodev.h - not found                                                                                                    
-- Looking for linux/videodev2.h                                             
-- Looking for linux/videodev2.h - found                                       
-- Looking for sys/videoio.h                                                                                                                                                    
-- Looking for sys/videoio.h - not found 

解决:

apt-get install libv4l-dev
ln -s /usr/include/libv4l1-videodev.h  /usr/include/linux/videodev.h
  1. CMake Error: The following variables are used in this project, but they are set to NOTFOUND. CUDA_nppi_LIBRARY (ADVANCED)

原因:cuda9不再支持2.0架构

解决方法1:见链接
解决方法2:在cmake命令中指定nppicom库的路径(可以随机给一个已存在的库路径,如nppicc)

cmake -D CUDA_nppicom_LIBRARY=/usr/local/cuda/lib64/libnppicc.so ..
  1. CMake Error at cmake/OpenCVDetectCXXCompiler.cmake:89 (math): math cannot parse the expression: "*100 + ": syntax error, unexpectedDetected version of GNU GCC: (ERROR)

原因:Ubuntu 18.4不支持opencv-2.3.10自带的OpenCVDetectCXXCompiler.cmake,GNU GCC版本判断问题

解决方法:见连接

make 过程

  1. nvcc fatal : Unsupported gpu architecture 'compute_30'
  • 解决方法:在cmake时指定使用Kepler,注意要在cmake/OpenCVDetectCUDA.cmake文件中找到if(CUDA_GENERATION STREQUAL "Kepler")行,将其下面的set(__cuda_arch_bin "x.x x.x")中包含上面计算力的数字删掉。
    set(__cuda_arch_bin "3.0 3.5 3.7")改为set(__cuda_arch_bin "3.5 3.7")
cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local -D CUDA_GENERATION=Kepler ..
  1. NCVPixelOperations.hpp(51): error: a storage class is not allowed in an explicit specialization
    原因:这是由于NCVPixelOperations.hpp的问题
    解决方案:修改modules/gpu/src/nvidia/core/NCVPixelOperations.hpp文件,将文件里的的static inline 修改成 inline就可以了。记得重新cmake。
  2. make[2]: *** [modules/gpu/CMakeFiles/opencv_gpu.dir/build.make:923: modules/gpu/CMakeFiles/opencv_gpu.dir/src/graphcuts.cpp.o] Error 1 make[2]: *** Waiting for unfinished jobs....
    解决方案:修改graphcuts.cpp文件
#if !defined (HAVE_CUDA) || defined (CUDA_DISABLER)
改为:
#if !defined (HAVE_CUDA) || defined (CUDA_DISABLER) || (CUDART_VERSION >= 8000)
  1. error: the compiler can assume that the address of ‘annotate_img’ will never be NULL
    问题:
/data/project/TIA-py3/OpenCV/modules/contrib/src/chamfermatching.cpp:969:30: error: the compiler can assume that the address of ‘annotate_img’ will never be NULL [-Werror=address]
  969 |             if (&annotate_img!=NULL) {     
      |                              ^
/data/project/TIA-py3/OpenCV/modules/contrib/src/chamfermatching.cpp:1016:34: error: the compiler can assume that the address of ‘annotate_img’ will never be NULL [-Werror=address]                         
 1016 |                 if (&annotate_img!=NULL) {                      
      |                                  ^                    
/data/project/TIA-py3/OpenCV/modules/contrib/src/chamfermatching.cpp: In member function ‘cv::ChamferMatcher::Match* cv::ChamferMatcher::Matching::localChamferDistance(cv::Point, cv::Mat&, cv::Mat&, cv::Ch
amferMatcher::Template*, float)’:                                                                                                                                                                            
/data/project/TIA-py3/OpenCV/modules/contrib/src/chamfermatching.cpp:1111:25: error: the compiler can assume that the address of ‘orientation_img’ will never be NULL [-Werror=address]                  
 1111 |     if (&orientation_img!=NULL) {  

解决方法:
找到opencv-2.4.10/build/modules/contrib/CMakeFiles/opencv_contrib.dir/flags.make文件,删掉-Werror=address,然后重新 make -j7。注意:可能要重复修改两次make

参考

  1. ubuntu 18.04安装opencv-2.4.10遇错解决
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值