Cmake error when I try install Opencv 3.1

I want to compile and install OpenCV 3.1 on my Ubuntu 15.10. I followed this tutorial. After I ran the cmake command, the installation begin, but the process return error, and ALL FILES IN MY UBUNTU TURNED READ-ONLY!

Here is the input log: http://pastebin.com/vJz0U7es

I don't understand cmake very well. Can Somebody help me?


It is a known issue with 16.04. A bug report has been filled already and should be fixed soon. For now, I fixed it doing this:

sudo -i
mkdir /usr/include/ffmpeg
cd /usr/include/ffmpeg
ln -sf /usr/include/x86_64-linux-gnu/libavcodec/*.h ./
ln -sf /usr/include/x86_64-linux-gnu/libavformat/*.h ./
ln -sf /usr/include/x86_64-linux-gnu/libswscale/*.h ./

Basically, you create links in /usr/include/ffmpeg to all .h files in the directories: /usr/include/x86_64-linux-gnu/libavcodec/ /usr/include/x86_64-linux-gnu/libavformat/ /usr/include/x86_64-linux-gnu/libswscale/

I managed to avoid the sys/videoio.h issue and the linux/videodev.h issue by using the following cmake command (note you must have opencv_contrib checkedout and adjust the relative path below to your case). You also must run this cmake command twice or the Python3 part for some reason does not gets picked up. I do not know why the cmake command below fixed the issues to me, I just found it out after a long investigation (maybe with the cmake command below the fix above is not even necessary, I do not know).

cmake \
  -D CMAKE_BUILD_TYPE=RELEASE \
  -D CMAKE_INSTALL_PREFIX=/usr/local \
  -D WITH_TBB=ON \
  -D WITH_V4L=ON \
  -D WITH_QT=ON \
  -D WITH_OPENGL=ON \
  -D WITH_CUDA=ON \
  -D ENABLE_FAST_MATH=1 \
  -D CUDA_FAST_MATH=1 \
  -D CUDA_NVCC_FLAGS="-D_FORCE_INLINES" \
  -D WITH_CUBLAS=1 \
  -D OPENCV_EXTRA_MODULES_PATH=../../opencv_contrib/modules \
  -D BUILD_TESTS=OFF \
  -D BUILD_PERF_TESTS=OFF \
  -D BUILD_OPENCV_PYTHON3=1 \
  -D PYTHON3_EXECUTABLE=$(which python3) \
  -D PYTHON3_INCLUDE_DIR=$(python3 -c "from distutils.sysconfig import get_python_inc; print(get_python_inc())") \
  -D PYTHON3_LIBRARIES=$(python3 -c "from distutils.sysconfig import get_python_lib; print(get_python_lib())") ..