[問題]  
opencvの環境作りのためにcmakeしたのですが、errorが出てしまいます。

[環境]  
ubuntu 18.04  
pyenv上でanaconda3-5.3.1  
opencv4.0.1とcontrib4.0.1の導入

[手順]  
[このリンク](http://beetreehitsuji.hatenablog.com/entry/2019/02/14/154829)に従いました。但し、workフォルダは作っていません。  
`cmake -D CMAKE_BUILD_TYPE=Release -D CMAKE_INSTALL_PREFIX=/usr/local -D
OPENCV_EXTRA_MODULES_PATH=../../opencv_contrib/modules
..`をしようとしたら、次のようなエラーが出ました。

```

    (cv) (anaconda3-5.3.1/envs/cv) qcmp@qcmp-Alienware-Aurora-R8:~/opencv/build$ cmake -D CMAKE_BUILD_TYPE=Release -D CMAKE_INSTALL_PREFIX=/usr/local -D OPENCV_EXTRA_MODULES_PATH=../../opencv_contrib/modules ..
    -- Looking for ccache - found (/usr/bin/ccache)
    -- WARNING: Option ENABLE_AVX='ON' is deprecated and should not be used anymore
    --          Behaviour of this option is not backward compatible
    --          Refer to 'CPU_BASELINE'/'CPU_DISPATCH' CMake options documentation
    -- Found ZLIB: /usr/lib/x86_64-linux-gnu/libz.so (found suitable version "1.2.11", minimum required is "1.2.3") 
    -- Could NOT find Jasper (missing: JASPER_LIBRARIES JASPER_INCLUDE_DIR) 
    -- Found ZLIB: /usr/lib/x86_64-linux-gnu/libz.so (found version "1.2.11") 
    CMake Warning (dev) at /home/qcmp/.pyenv/versions/anaconda3-5.3.1/envs/cv/lib/python3.7/site-packages/cmake/data/share/cmake-3.15/Modules/FindOpenGL.cmake:275 (message):
      Policy CMP0072 is not set: FindOpenGL prefers GLVND by default when
      available.  Run "cmake --help-policy CMP0072" for policy details.  Use the
      cmake_policy command to set the policy and suppress this warning.
    
      FindOpenGL found both a legacy GL library:
    
        OPENGL_gl_LIBRARY: /usr/lib/x86_64-linux-gnu/libGL.so
    
      and GLVND libraries for OpenGL and GLX:
    
        OPENGL_opengl_LIBRARY: /usr/lib/x86_64-linux-gnu/libOpenGL.so
        OPENGL_glx_LIBRARY: /usr/lib/x86_64-linux-gnu/libGLX.so
    
      OpenGL_GL_PREFERENCE has not been set to "GLVND" or "LEGACY", so for
      compatibility with CMake 3.10 and below the legacy GL library will be used.
    Call Stack (most recent call first):
      cmake/OpenCVFindLibsGUI.cmake:70 (find_package)
      CMakeLists.txt:767 (include)
    This warning is for project developers.  Use -Wno-dev to suppress it.
    
    -- Checking for module 'libavresample'
    --   No package 'libavresample' found
    -- Found TBB (env): /usr/lib/x86_64-linux-gnu/libtbb.so
    -- found Intel IPP (ICV version): 2019.0.0 [2019.0.0 Gold]
    -- at: /home/qcmp/opencv/build/3rdparty/ippicv/ippicv_lnx/icv
    -- found Intel IPP Integration Wrappers sources: 2019.0.0
    -- at: /home/qcmp/opencv/build/3rdparty/ippicv/ippicv_lnx/iw
    -- Could not find OpenBLAS include. Turning OpenBLAS_FOUND off
    -- Could not find OpenBLAS lib. Turning OpenBLAS_FOUND off
    -- Could NOT find Atlas (missing: Atlas_CLAPACK_INCLUDE_DIR) 
    -- A library with LAPACK API found.
    -- Could NOT find JNI (missing: JAVA_AWT_LIBRARY JAVA_JVM_LIBRARY JAVA_INCLUDE_PATH JAVA_INCLUDE_PATH2 JAVA_AWT_INCLUDE_PATH) 
    -- Could NOT find Flake8 (missing: FLAKE8_EXECUTABLE) 
    CMake Error at cmake/OpenCVModule.cmake:288 (message):
      No modules has been found: /home/qcmp/opencv_contrib/modules
    Call Stack (most recent call first):
      cmake/OpenCVModule.cmake:370 (_glob_locations)
      modules/CMakeLists.txt:7 (ocv_glob_modules)
    
    
    -- OpenCV Python: during development append to PYTHONPATH: /home/qcmp/opencv/build/python_loader
    -- OpenCL samples are skipped: OpenCL SDK is required
    -- Pylint: registered 168 targets. Build 'check_pylint' target to run checks ("cmake --build . --target check_pylint" or "make check_pylint")
    -- 
    -- General configuration for OpenCV 4.0.1 =====================================
    --   Version control:               4.0.1
    -- 
    --   Platform:
    --     Timestamp:                   2019-10-16T07:27:08Z
    --     Host:                        Linux 4.15.0-64-generic x86_64
    --     CMake:                       3.15.3
    --     CMake generator:             Unix Makefiles
    --     CMake build tool:            /usr/bin/make
    --     Configuration:               Release
    -- 
    --   CPU/HW features:
    --     Baseline:                    SSE SSE2 SSE3 SSSE3 SSE4_1 POPCNT SSE4_2 AVX
    --       requested:                 SSE3
    --       required:                  AVX
    --     Dispatched code generation:  FP16 AVX2 AVX512_SKX
    --       requested:                 SSE4_1 SSE4_2 AVX FP16 AVX2 AVX512_SKX
    --       FP16 (0 files):            + FP16
    --       AVX2 (11 files):           + FP16 FMA3 AVX2
    --       AVX512_SKX (1 files):      + FP16 FMA3 AVX2 AVX_512F AVX512_SKX
    -- 
    --   C/C++:
    --     Built as dynamic libs?:      YES
    --     C++ Compiler:                /usr/bin/c++  (ver 7.4.0)
    --     C++ flags (Release):         -fsigned-char -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wuninitialized -Winit-self -Wsuggest-override -Wno-narrowing -Wno-delete-non-virtual-dtor -Wno-comment -Wimplicit-fallthrough=3 -Wno-strict-overflow -fdiagnostics-show-option -Wno-long-long -pthread -fomit-frame-pointer -ffunction-sections -fdata-sections  -msse -msse2 -msse3 -mssse3 -msse4.1 -mpopcnt -msse4.2 -mavx -fvisibility=hidden -fvisibility-inlines-hidden -O3 -DNDEBUG  -DNDEBUG
    --     C++ flags (Debug):           -fsigned-char -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wuninitialized -Winit-self -Wsuggest-override -Wno-narrowing -Wno-delete-non-virtual-dtor -Wno-comment -Wimplicit-fallthrough=3 -Wno-strict-overflow -fdiagnostics-show-option -Wno-long-long -pthread -fomit-frame-pointer -ffunction-sections -fdata-sections  -msse -msse2 -msse3 -mssse3 -msse4.1 -mpopcnt -msse4.2 -mavx -fvisibility=hidden -fvisibility-inlines-hidden -g  -O0 -DDEBUG -D_DEBUG
    --     C Compiler:                  /usr/bin/cc
    --     C flags (Release):           -fsigned-char -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wuninitialized -Winit-self -Wno-narrowing -Wno-comment -Wimplicit-fallthrough=3 -Wno-strict-overflow -fdiagnostics-show-option -Wno-long-long -pthread -fomit-frame-pointer -ffunction-sections -fdata-sections  -msse -msse2 -msse3 -mssse3 -msse4.1 -mpopcnt -msse4.2 -mavx -fvisibility=hidden -O3 -DNDEBUG  -DNDEBUG
    --     C flags (Debug):             -fsigned-char -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wuninitialized -Winit-self -Wno-narrowing -Wno-comment -Wimplicit-fallthrough=3 -Wno-strict-overflow -fdiagnostics-show-option -Wno-long-long -pthread -fomit-frame-pointer -ffunction-sections -fdata-sections  -msse -msse2 -msse3 -mssse3 -msse4.1 -mpopcnt -msse4.2 -mavx -fvisibility=hidden -g  -O0 -DDEBUG -D_DEBUG
    --     Linker flags (Release):      
    --     Linker flags (Debug):        
    --     ccache:                      YES
    --     Precompiled headers:         NO
    --     Extra dependencies:          dl m pthread rt /usr/lib/x86_64-linux-gnu/libGL.so /usr/lib/x86_64-linux-gnu/libGLU.so
    --     3rdparty dependencies:
    -- 
    --   OpenCV modules:
    --     To be built:                 calib3d core dnn features2d flann gapi highgui imgcodecs imgproc java_bindings_generator ml objdetect photo python_bindings_generator stitching ts video videoio
    --     Disabled:                    python2 world
    --     Disabled by dependency:      -
    --     Unavailable:                 java js python3
    --     Applications:                examples apps
    --     Documentation:               NO
    --     Non-free algorithms:         YES
    -- 
    --   GUI: 
    --     QT:                          YES (ver 5.9.7)
    --       QT OpenGL support:         YES (Qt5::OpenGL 5.9.7)
    --     GTK+:                        NO
    --     OpenGL support:              YES (/usr/lib/x86_64-linux-gnu/libGL.so /usr/lib/x86_64-linux-gnu/libGLU.so)
    -- 
    --   Media I/O: 
    --     ZLib:                        /usr/lib/x86_64-linux-gnu/libz.so (ver 1.2.11)
    --     JPEG:                        /usr/lib/x86_64-linux-gnu/libjpeg.so (ver 80)
    --     WEBP:                        build (ver encoder: 0x020e)
    --     PNG:                         /usr/lib/x86_64-linux-gnu/libpng.so (ver 1.6.34)
    --     TIFF:                        build (ver 42 - 4.0.9)
    --     JPEG 2000:                   build (ver 1.900.1)
    --     OpenEXR:                     build (ver 1.7.1)
    --     HDR:                         YES
    --     SUNRASTER:                   YES
    --     PXM:                         YES
    --     PFM:                         YES
    -- 
    --   Video I/O:
    --     DC1394:                      YES (ver 2.2.5)
    --     FFMPEG:                      YES
    --       avcodec:                   YES (ver 57.107.100)
    --       avformat:                  YES (ver 57.83.100)
    --       avutil:                    YES (ver 55.78.100)
    --       swscale:                   YES (ver 4.8.100)
    --       avresample:                NO
    --     GStreamer:                   
    --       base:                      YES (ver 1.14.5)
    --       video:                     YES (ver 1.14.5)
    --       app:                       YES (ver 1.14.5)
    --       riff:                      YES (ver 1.14.5)
    --       pbutils:                   YES (ver 1.14.5)
    -- 
    --   Parallel framework:            TBB (ver 2017.0 interface 9107)
    -- 
    --   Trace:                         YES (with Intel ITT)
    -- 
    --   Other third-party libraries:
    --     Intel IPP:                   2019.0.0 Gold [2019.0.0]
    --            at:                   /home/qcmp/opencv/build/3rdparty/ippicv/ippicv_lnx/icv
    --     Intel IPP IW:                sources (2019.0.0)
    --               at:                /home/qcmp/opencv/build/3rdparty/ippicv/ippicv_lnx/iw
    --     Lapack:                      NO
    --     Eigen:                       NO
    --     Custom HAL:                  NO
    --     Protobuf:                    build (3.5.1)
    -- 
    --   OpenCL:                        YES (no extra features)
    --     Include path:                /home/qcmp/opencv/3rdparty/include/opencl/1.2
    --     Link libraries:              Dynamic load
    -- 
    --   Python 3:
    --     Interpreter:                 home/qcmp/.pyenv/versions/anaconda3-5.3.1/envs/cv/bin/python (ver 3.5.1)
    --     Libraries:                   NO
    --     numpy:                       /home/qcmp/.pyenv/versions/anaconda3-4.0.0/lib/python3.5/site-packages/numpy/core/include (ver 1.10.4)
    --     install path:                -
    -- 
    --   Python (for build):            /usr/bin/python2.7
    --     Pylint:                      /home/qcmp/anaconda3/bin/pylint (ver: 3.7.3, checks: 168)
    -- 
    --   Java:                          
    --     ant:                         NO
    --     JNI:                         NO
    --     Java wrappers:               NO
    --     Java tests:                  NO
    -- 
    --   Install to:                    /usr/local
    -- -----------------------------------------------------------------
    -- 
    -- Configuring incomplete, errors occurred!
    See also "/home/qcmp/opencv/build/CMakeFiles/CMakeOutput.log".
    See also "/home/qcmp/opencv/build/CMakeFiles/CMakeError.log".
    
    
```

CMakeError.logは以下のようになっています。

```

    Determining if the include file sys/videoio.h exists failed with the following output:
    Change Dir: /home/qcmp/opencv/build/CMakeFiles/CMakeTmp
    
    Run Build Command:"/usr/bin/make" "cmTC_0de62/fast"
    /usr/bin/make -f CMakeFiles/cmTC_0de62.dir/build.make CMakeFiles/cmTC_0de62.dir/build
    make[1]: ディレクトリ '/home/qcmp/opencv/build/CMakeFiles/CMakeTmp' に入ります
    Building C object CMakeFiles/cmTC_0de62.dir/CheckIncludeFile.c.o
    /usr/bin/cc   -fsigned-char -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wuninitialized -Winit-self -Wno-narrowing -Wno-comment -Wimplicit-fallthrough=3 -Wno-strict-overflow -fdiagnostics-show-option -Wno-long-long -pthread -fomit-frame-pointer -ffunction-sections -fdata-sections  -msse -msse2 -msse3 -mssse3 -msse4.1 -mpopcnt -msse4.2 -mavx -fvisibility=hidden  -O3 -DNDEBUG -fPIE   -o CMakeFiles/cmTC_0de62.dir/CheckIncludeFile.c.o   -c /home/qcmp/opencv/build/CMakeFiles/CMakeTmp/CheckIncludeFile.c
    /home/qcmp/opencv/build/CMakeFiles/CMakeTmp/CheckIncludeFile.c:1:10: fatal error: sys/videoio.h: そのようなファイルやディレクトリはありません
     #include <sys/videoio.h>
              ^~~~~~~~~~~~~~~
    compilation terminated.
    CMakeFiles/cmTC_0de62.dir/build.make:65: recipe for target 'CMakeFiles/cmTC_0de62.dir/CheckIncludeFile.c.o' failed
    make[1]: *** [CMakeFiles/cmTC_0de62.dir/CheckIncludeFile.c.o] Error 1
    make[1]: ディレクトリ '/home/qcmp/opencv/build/CMakeFiles/CMakeTmp' から出ます
    Makefile:126: recipe for target 'cmTC_0de62/fast' failed
    make: *** [cmTC_0de62/fast] Error 2
    
    
    Build output check failed:
        Regex: 'command line option .* is valid for .* but not for C'
        Output line: 'cc1: warning: command line option ‘-Wsuggest-override’ is valid for C++/ObjC++ but not for C'
    Compilation failed:
        source file: '/home/qcmp/opencv/build/CMakeFiles/CMakeTmp/src.c'
        check option: ' -fsigned-char -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wuninitialized -Winit-self  -Wsuggest-override'
    ===== BUILD LOG =====
    Change Dir: /home/qcmp/opencv/build/CMakeFiles/CMakeTmp
    
    Run Build Command:"/usr/bin/make" "cmTC_22a6c/fast"
    /usr/bin/make -f CMakeFiles/cmTC_22a6c.dir/build.make CMakeFiles/cmTC_22a6c.dir/build
    make[1]: ディレクトリ '/home/qcmp/opencv/build/CMakeFiles/CMakeTmp' に入ります
    Building C object CMakeFiles/cmTC_22a6c.dir/src.c.o
    /usr/bin/cc   -O3 -DNDEBUG -fPIE   -fsigned-char -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wuninitialized -Winit-self -Wsuggest-override -o CMakeFiles/cmTC_22a6c.dir/src.c.o   -c /home/qcmp/opencv/build/CMakeFiles/CMakeTmp/src.c
    cc1: warning: command line option ‘-Wsuggest-override’ is valid for C++/ObjC++ but not for C
    /home/qcmp/opencv/build/CMakeFiles/CMakeTmp/src.c:1:0: warning: ignoring #pragma   [-Wunknown-pragmas]
     #pragma
    
    Linking C executable cmTC_22a6c
    /usr/bin/cmake -E cmake_link_script CMakeFiles/cmTC_22a6c.dir/link.txt --verbose=1
    /usr/bin/cc   -O3 -DNDEBUG    CMakeFiles/cmTC_22a6c.dir/src.c.o  -o cmTC_22a6c
    make[1]: ディレクトリ '/home/qcmp/opencv/build/CMakeFiles/CMakeTmp' から出ます
    
    ===== END =====
    
    Determining if the function cheev_ exists failed with the following output:
    Change Dir: /home/qcmp/opencv/build/CMakeFiles/CMakeTmp
    
    Run Build Command(s):/usr/bin/make cmTC_2365c/fast && /usr/bin/make -f CMakeFiles/cmTC_2365c.dir/build.make CMakeFiles/cmTC_2365c.dir/build
    make[1]: ディレクトリ '/home/qcmp/opencv/build/CMakeFiles/CMakeTmp' に入ります
    Building C object CMakeFiles/cmTC_2365c.dir/CheckFunctionExists.c.o
    /usr/bin/cc   -fsigned-char -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wuninitialized -Winit-self -Wno-narrowing -Wno-comment -Wimplicit-fallthrough=3 -Wno-strict-overflow -fdiagnostics-show-option -Wno-long-long -pthread -fomit-frame-pointer -ffunction-sections -fdata-sections  -msse -msse2 -msse3 -mssse3 -msse4.1 -mpopcnt -msse4.2 -mavx -fvisibility=hidden -DCHECK_FUNCTION_EXISTS=cheev_ -O3 -DNDEBUG -fPIE   -o CMakeFiles/cmTC_2365c.dir/CheckFunctionExists.c.o   -c /home/qcmp/.pyenv/versions/anaconda3-5.3.1/envs/cv/lib/python3.7/site-packages/cmake/data/share/cmake-3.15/Modules/CheckFunctionExists.c
    Linking C executable cmTC_2365c
    /home/qcmp/.pyenv/versions/anaconda3-5.3.1/envs/cv/lib/python3.7/site-packages/cmake/data/bin/cmake -E cmake_link_script CMakeFiles/cmTC_2365c.dir/link.txt --verbose=1
    /usr/bin/cc    -fsigned-char -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wuninitialized -Winit-self -Wno-narrowing -Wno-comment -Wimplicit-fallthrough=3 -Wno-strict-overflow -fdiagnostics-show-option -Wno-long-long -pthread -fomit-frame-pointer -ffunction-sections -fdata-sections  -msse -msse2 -msse3 -mssse3 -msse4.1 -mpopcnt -msse4.2 -mavx -fvisibility=hidden -DCHECK_FUNCTION_EXISTS=cheev_ -O3 -DNDEBUG    -Wl,--gc-sections  CMakeFiles/cmTC_2365c.dir/CheckFunctionExists.c.o  -o cmTC_2365c
    CMakeFiles/cmTC_2365c.dir/CheckFunctionExists.c.o: 関数 `main' 内:
    CheckFunctionExists.c:(.text.startup.main+0xc): `cheev_' に対する定義されていない参照です
    collect2: error: ld returned 1 exit status
    CMakeFiles/cmTC_2365c.dir/build.make:86: recipe for target 'cmTC_2365c' failed
    make[1]: *** [cmTC_2365c] Error 1
    make[1]: ディレクトリ '/home/qcmp/opencv/build/CMakeFiles/CMakeTmp' から出ます
    Makefile:121: recipe for target 'cmTC_2365c/fast' failed
    make: *** [cmTC_2365c/fast] Error 2
    
    
    
```

CMakeOutput.logは文字数の関係で載せられません。  
CMakeError.logみると、sys/videoio.hファイルが存在しないとあるので、cmakeのオプション設定でオフにすればよいと、[このリンク](https://qiita.com/----_/items/8131b1b2ddaef6b0d18d)にありました。しかし、CMakeError.logからは消えませんでした。そもそも  
[このリンク](https://heruwakame.hatenablog.com/entry/2017/10/15/172454)を見ると、それをやらなくても大丈夫だといいます。

どこに目をつけてどう直せば良いのかわからなくなってしまったので、指針をご教授いただきたいです。
CC BY-SA 4.0
2019-10-21T08:26:09.143
59846
2022-03-02T02:05:30.517
32582
question
cmake
cmake エラーのデバッグ方法
解決しました。  
`CMake Error at cmake/OpenCVModule.cmake:288 (message):  
No modules has been found: /home/qcmp/opencv_contrib/modules`  
とあるように、指定された場所に`opencv_contrib`がありませんでした。`opencv_contrib`は`/home/qcmp/opencv/release/opencv_contrib`置いていました。色々なサイトを見て実装したので、ファイルの場所がごちゃごちゃになったのが原因でした。
CC BY-SA 4.0
2019-10-21T11:18:06.833
59851
2019-10-21T11:18:06.833
32582
59846
answer