由于在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做准备