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 ..
videodev.h
,videodev2.h
,videoio.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
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 ..
CMake Error at cmake/OpenCVDetectCXXCompiler.cmake:89 (math): math cannot parse the expression: "*100 + ": syntax error, unexpected
和Detected version of GNU GCC: (ERROR)
原因:Ubuntu 18.4不支持opencv-2.3.10自带的OpenCVDetectCXXCompiler.cmake,GNU GCC版本判断问题
解决方法:见连接
make 过程
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 ..
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。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)
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