Compiling OpenCV 3.3 : C++11 is not supported

I finally compile OpenCV 3.3 from source successfully, however I still don't know why it wouldn't compile before. All what I had modified is the flag OPENCV_EXTRA_MODULES_PATH to the reference where the source files of the modules of opencv_contrib 3.3.0 are, like so:

$ cmake \
-D CMAKE_BUILD_TYPE=RELEASE \
-D CMAKE_INSTALL_PREFIX=/usr/local \
-D WITH_CUDA=ON \
-D ENABLE_FAST_MATH=1 \
-D CUDA_FAST_MATH=1 \
-D WITH_CUBLAS=1 \
-D INSTALL_C_EXAMPLES=OFF \
-D INSTALL_PYTHON_EXAMPLES=ON \
-D OPENCV_EXTRA_MODULES_PATH=/home/jhros/opencv-3.3.0/opencv_contrib-3.3.0/modules  \
-D BUILD_SHARED_LIBS=ON \
-D WITH_GTK=ON \    
-D BUILD_EXAMPLES=ON ..  

I got an infinite number of warnings of kind (and many others):

warning: dynamic exception specifications are deprecated in C++11

And also you might get an error with newer version of GCC which is not supported by cuda:

#error -- unsupported GNU version! gcc versions later than 5 are not supported!

But this could be solved by setting cmake to use older version of GCC while compiling OpenCV

CMAKE_C_COMPILER=/usr/bin/gcc-5

I installed OpenCV 3.3.1 on Linux Mint 18.2, followed this article (https://www.learnopencv.com/install-opencv3-on-ubuntu/) and I had the same problem. I changed cmake command from

cmake -D CMAKE_BUILD_TYPE=RELEASE \
  -D CMAKE_INSTALL_PREFIX=/usr/local \
  -D INSTALL_C_EXAMPLES=ON \
  -D INSTALL_PYTHON_EXAMPLES=ON \
  -D WITH_TBB=ON \
  -D WITH_V4L=ON \
  -D WITH_QT=ON \
  -D WITH_OPENGL=ON \
  -D OPENCV_EXTRA_MODULES_PATH=../../opencv_contrib/modules \
  -D BUILD_EXAMPLES=ON ..

to

cmake -D CMAKE_BUILD_TYPE=RELEASE \
  -DCMAKE_INSTALL_PREFIX=/usr/local \
  -D INSTALL_C_EXAMPLES=OFF \
  -D INSTALL_PYTHON_EXAMPLES=OFF \
  -D WITH_TBB=ON \
  -D WITH_V4L=ON \
  -D WITH_QT=ON \
  -D WITH_OPENGL=ON \
  -D OPENCV_EXTRA_MODULES_PATH=../../opencv_contrib/modules \
  -D BUILD_EXAMPLES=OFF ..

(changed from -D CMAKE_INSTALL_PREFIX=/usr/local \ to -DCMAKE_INSTALL_PREFIX=/usr/local \) and it worked for me. Hope useful. Note: 3.3.0 is not work. (Sorry about my English)


i also had this error, and add argument OPENCV_EXTRA_MODULES_PATH point to the opencv_contrib solved it