openCV를 설치하는 과정에서 에러를 만났습니다. 에러를 만난 과정은 다음과 같습니다.

  1. opencv and opencv_contrib 다운로드
  2. 그리고 다음 명령어를 통해 cmake
cmake -D CMAKE_BUILD_TYPE=RELEASE \
-D CMAKE_INSTALL_PREFIX=/usr/local \
-D WITH_TBB=OFF \
-D WITH_IPP=OFF \
-D WITH_1394=OFF \
-D BUILD_WITH_DEBUG_INFO=OFF \
-D BUILD_DOCS=OFF \
-D INSTALL_C_EXAMPLES=ON \
-D INSTALL_PYTHON_EXAMPLES=ON \
-D BUILD_EXAMPLES=OFF \
-D BUILD_TESTS=OFF \
-D BUILD_PERF_TESTS=OFF \
-D WITH_QT=ON \
-D WITH_OPENGL=ON \
-D OPENCV_EXTRA_MODULES_PATH=../../opencv_contrib-3.4.0/modules \
-D WITH_V4L=ON  \
-D WITH_FFMPEG=ON \
-D WITH_XINE=ON \
-D BUILD_NEW_PYTHON_SUPPORT=ON \
../
  1. make -j4
  2. 23%에서 오류 발생
...
Scanning dependencies of target pch_Generate_opencv_stitching
[ 24%] Generating precomp.hpp
[ 24%] Generating precomp.hpp.gch/opencv_stitching_RELEASE.gch
[ 24%] Built target pch_Generate_opencv_bgsegm
[ 24%] Processing OpenCL kernels (core)
[ 24%] Building NVCC (Device) object modules/core/CMakeFiles/cuda_compile.dir/src/cuda/cuda_compile_generated_gpu_mat.cu.o
In file included from /usr/local/cuda-9.0/include/host_config.h:50:0,
                 from /usr/local/cuda-9.0/include/cuda_runtime.h:78,
                 from <command-line>:0:
/usr/local/cuda-9.0/include/crt/host_config.h:119:2: error: #error -- unsupported GNU version! gcc versions later than 6 are not supported!
 #error -- unsupported GNU version! gcc versions later than 6 are not supported!
  ^~~~~
CMake Error at cuda_compile_generated_gpu_mat.cu.o.cmake:208 (message):
  Error generating
  /home/eungbean/opencv/opencv-3.4.0/build/modules/core/CMakeFiles/cuda_compile.dir/src/cuda/./cuda_compile_generated_gpu_mat.cu.o


modules/core/CMakeFiles/opencv_core.dir/build.make:63: recipe for target 'modules/core/CMakeFiles/cuda_compile.dir/src/cuda/cuda_compile_generated_gpu_mat.cu.o' failed
make[2]: *** [modules/core/CMakeFiles/cuda_compile.dir/src/cuda/cuda_compile_generated_gpu_mat.cu.o] Error 1
CMakeFiles/Makefile2:2299: recipe for target 'modules/core/CMakeFiles/opencv_core.dir/all' failed
make[1]: *** [modules/core/CMakeFiles/opencv_core.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs....
In file included from /home/eungbean/opencv/opencv-3.4.0/modules/cudalegacy/include/opencv2/cudalegacy.hpp:50:0,
                 from /home/eungbean/opencv/opencv-3.4.0/build/modules/stitching/precomp.hpp:87:
/home/eungbean/opencv/opencv-3.4.0/modules/cudalegacy/include/opencv2/cudalegacy/NCVHaarObjectDetection.hpp: In member function ‘NCVStatus HaarFeature64::setRect(Ncv32u, Ncv32u, Ncv32u, Ncv32u, Ncv32u, Ncv32u)’:
/home/eungbean/opencv/opencv-3.4.0/modules/cudalegacy/include/opencv2/cudalegacy/NCVHaarObjectDetection.hpp:87:38: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
         ((NcvRect8u*)&(this->_ui2.x))->x = (Ncv8u)rectX;
                                      ^~
/home/eungbean/opencv/opencv-3.4.0/modules/cudalegacy/include/opencv2/cudalegacy/NCVHaarObjectDetection.hpp:88:38: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
         ((NcvRect8u*)&(this->_ui2.x))->y = (Ncv8u)rectY;
                                      ^~
/home/eungbean/opencv/opencv-3.4.0/modules/cudalegacy/include/opencv2/cudalegacy/NCVHaarObjectDetection.hpp:89:38: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
         ((NcvRect8u*)&(this->_ui2.x))->width = (Ncv8u)rectWidth;
                                      ^~
/home/eungbean/opencv/opencv-3.4.0/modules/cudalegacy/include/opencv2/cudalegacy/NCVHaarObjectDetection.hpp:90:38: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
         ((NcvRect8u*)&(this->_ui2.x))->height = (Ncv8u)rectHeight;
                                      ^~
/home/eungbean/opencv/opencv-3.4.0/modules/cudalegacy/include/opencv2/cudalegacy/NCVHaarObjectDetection.hpp: In member function ‘void HaarFeature64::getRect(Ncv32u*, Ncv32u*, Ncv32u*, Ncv32u*)’:
/home/eungbean/opencv/opencv-3.4.0/modules/cudalegacy/include/opencv2/cudalegacy/NCVHaarObjectDetection.hpp:102:56: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
         NcvRect8u tmpRect = *(NcvRect8u*)(&this->_ui2.x);
                                                        ^
/home/eungbean/opencv/opencv-3.4.0/modules/cudalegacy/include/opencv2/cudalegacy/NCVHaarObjectDetection.hpp:102:56: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
[ 24%] Built target pch_Generate_opencv_face
[ 24%] Built target pch_Generate_opencv_optflow
[ 24%] Built target pch_Generate_opencv_stitching
Makefile:162: recipe for target 'all' failed
make: *** [all] Error 2

아..머리아프다…

검색!

구글링 해본 결과 다음과 같은 게시물을 찾았습니다.

181204-protobuf

답변은 protobuf가 제대로 설치되지 않았을거라는 말이었습니다.

protobuf 설치

아래 방법을 따라 protobuf를 설치했습니다.

설치 방법

  1. https://developers.google.com/protocol-buffers/ 에서 다운로드

  2. 압축 풀기
    tar -xf protobuf-all-3.6.1.tar.gz
    cd protobuf-all-3.6.1
    
  3. 빌드
sudo ./configure
sudo make
sudo make check
sudo make install
  1. 캐쉬 반영
sudo ldconfig
  1. 설치 확인
    protoc --version
    
  2. 임시파일들 삭제
cd ..
sudo rm -rf protobuf-*

gcc 버전 호환 문제

[ 24%] Built target pch_Generate_opencv_face
In file included from /usr/local/cuda-9.0/include/host_config.h:50:0,
                 from /usr/local/cuda-9.0/include/cuda_runtime.h:78,
                 from <command-line>:0:
/usr/local/cuda-9.0/include/crt/host_config.h:119:2: error: #error -- unsupported GNU version! gcc versions later than 6 are not supported!
 #error -- unsupported GNU version! gcc versions later than 6 are not supported!
  ^~~~~
CMake Error at cuda_compile_generated_gpu_mat.cu.o.cmake:208 (message):
  Error generating
  /home/eungbean/opencv/opencv-3.4.0/build/modules/core/CMakeFiles/cuda_compile.dir/src/cuda/./cuda_compile_generated_gpu_mat.cu.o


modules/core/CMakeFiles/opencv_core.dir/build.make:63: recipe for target 'modules/core/CMakeFiles/cuda_compile.dir/src/cuda/cuda_compile_generated_gpu_mat.cu.o' failed
make[2]: *** [modules/core/CMakeFiles/cuda_compile.dir/src/cuda/cuda_compile_generated_gpu_mat.cu.o] Error 1
CMakeFiles/Makefile2:2299: recipe for target 'modules/core/CMakeFiles/opencv_core.dir/all' failed
make[1]: *** [modules/core/CMakeFiles/opencv_core.dir/all] Error 2
Makefile:162: recipe for target 'all' failed
make: *** [all] Error 2

이번에는 unsupported GNU version 에러가 발생했다. gcc버전이 6보다 낮으면 지원되지 않는다고 한다.

sudo apt install gcc-6 g++-6
sudo ln -s /usr/bin/gcc-6 /usr/local/cuda/bin/gcc
sudo ln -s /usr/bin/g++-6 /usr/local/cuda/bin/g++
sudo apt install gcc-5 g++-5
sudo ln -s /usr/bin/gcc-5 /usr/local/cuda/bin/gcc
sudo ln -s /usr/bin/g++-5 /usr/local/cuda/bin/g++

Comments

Eungbean Lee's Picture

About Eungbean Lee

Lee is a Student, Programmer, Engineer, Designer and a DJ

Seoul, South Korea https://eungbean.github.io