CMake fails when building OpenCV (Ubuntu)

15,697

Thanks to hetepeperfan I was able to fix my problem. It turns out I was simply missing a C++ compiler.

After running sudo apt-get install build-essential and cleaning up my build folder and rerunning cmake the problem was fixed.

Share:
15,697
JREN
Author by

JREN

SOreadytohelp

Updated on June 04, 2022

Comments

  • JREN
    JREN almost 2 years

    I'm trying to build OpenCV with CMake but when I build it, some stuff goes wrong and I have no idea what to do to fix it.

    So the question basically is: How do I fix it?

    user@BEL-PC:~/opencv/build$ cmake -DBUILD_SHARED_LIBS=OFF ..
    -- The CXX compiler identification is unknown
    -- The C compiler identification is GNU
    -- Check for working C compiler: /usr/bin/gcc
    -- Check for working C compiler: /usr/bin/gcc -- works
    -- Detecting C compiler ABI info
    -- Detecting C compiler ABI info - done
    CMake Error: your CXX compiler: "CMAKE_CXX_COMPILER-NOTFOUND" was not found.   Please set CMAKE_CXX_COMPILER to a valid compiler path or name.
    -- Performing Test HAVE_CXX_FSIGNED_CHAR
    CMake Error at /usr/share/cmake-2.8/Modules/CMakeCXXInformation.cmake:37 (GET_FILENAME_COMPONENT):
      get_filename_component called with incorrect number of arguments
    Call Stack (most recent call first):
      CMakeLists.txt:2 (PROJECT)
    
    
    CMake Error: CMAKE_CXX_COMPILER not set, after EnableLanguage
    CMake Error: Internal CMake error, TryCompile configure of cmake failed
    -- Performing Test HAVE_CXX_FSIGNED_CHAR - Failed
    -- Performing Test HAVE_C_FSIGNED_CHAR
    -- Performing Test HAVE_C_FSIGNED_CHAR - Success
    -- Looking for pthread.h
    -- Looking for pthread.h - found
    -- Could NOT find ZLIB (missing:  ZLIB_LIBRARY ZLIB_INCLUDE_DIR) 
    -- Looking for fseeko
    -- Looking for fseeko - found
    -- Looking for unistd.h
    -- Looking for unistd.h - found
    -- Looking for sys/types.h
    -- Looking for sys/types.h - found
    -- Looking for stdint.h
    -- Looking for stdint.h - found
    -- Looking for stddef.h
    -- Looking for stddef.h - found
    -- Check size of off64_t
    -- Check size of off64_t - failed
    -- Could NOT find TIFF (missing:  TIFF_LIBRARY TIFF_INCLUDE_DIR) 
    CMake Error: your CXX compiler: "CMAKE_CXX_COMPILER-NOTFOUND" was not found.   Please set CMAKE_CXX_COMPILER to a valid compiler path or name.
    -- Looking for assert.h
    -- Looking for assert.h - found
    -- Looking for fcntl.h
    -- Looking for fcntl.h - found
    -- Looking for io.h
    -- Looking for io.h - not found
    -- Looking for jbg_newlen
    -- Looking for jbg_newlen - not found
    -- Looking for mmap
    -- Looking for mmap - found
    -- Looking for search.h
    -- Looking for search.h - found
    -- Looking for string.h
    -- Looking for string.h - found
    -- Looking for unistd.h
    -- Looking for unistd.h - found
    -- Could NOT find JPEG (missing:  JPEG_LIBRARY JPEG_INCLUDE_DIR) 
    CMake Error: your CXX compiler: "CMAKE_CXX_COMPILER-NOTFOUND" was not found.   Please set CMAKE_CXX_COMPILER to a valid compiler path or name.
    -- Found JPEG: libjpeg 
    -- Could NOT find Jasper (missing:  JASPER_LIBRARY JASPER_INCLUDE_DIR) 
    CMake Error: your CXX compiler: "CMAKE_CXX_COMPILER-NOTFOUND" was not found.   Please set CMAKE_CXX_COMPILER to a valid compiler path or name.
    -- Found ZLIB: zlib (found version "1.2.7")
    -- Could NOT find PNG (missing:  PNG_LIBRARY PNG_PNG_INCLUDE_DIR) 
    CMake Error: your CXX compiler: "CMAKE_CXX_COMPILER-NOTFOUND" was not found.   Please set CMAKE_CXX_COMPILER to a valid compiler path or name.
    CMake Error: your CXX compiler: "CMAKE_CXX_COMPILER-NOTFOUND" was not found.   Please set CMAKE_CXX_COMPILER to a valid compiler path or name.
    -- Looking for semaphore.h
    -- Looking for semaphore.h - found
    -- checking for module 'gtk+-2.0'
    --   package 'gtk+-2.0' not found
    -- checking for module 'gthread-2.0'
    --   package 'gthread-2.0' not found
    -- checking for module 'gstreamer-base-0.10'
    --   package 'gstreamer-base-0.10' not found
    -- checking for module 'libdc1394-2'
    --   package 'libdc1394-2' not found
    -- checking for module 'libdc1394'
    --   package 'libdc1394' not found
    -- checking for module 'libv4l1'
    --   package 'libv4l1' not found
    -- 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
    -- checking for module 'libavcodec'
    --   package 'libavcodec' not found
    -- checking for module 'libavformat'
    --   package 'libavformat' not found
    -- checking for module 'libavutil'
    --   package 'libavutil' not found
    -- checking for module 'libswscale'
    --   package 'libswscale' not found
    -- Looking for libavformat/avformat.h
    -- Looking for libavformat/avformat.h - not found
    -- Looking for ffmpeg/avformat.h
    -- Looking for ffmpeg/avformat.h - not found
    CMake Error at /usr/share/cmake-2.8/Modules/CMakeCXXInformation.cmake:37 (GET_FILENAME_COMPONENT):
      get_filename_component called with incorrect number of arguments
    Call Stack (most recent call first):
      CMakeLists.txt:2 (PROJECT)
    
    
    CMake Error: CMAKE_CXX_COMPILER not set, after EnableLanguage
    CMake Error: Internal CMake error, TryCompile configure of cmake failed
    -- Found PythonInterp: /usr/bin/python (found suitable version "2.7.3", required is "2.0")
    -- Could NOT find PythonLibs (missing:  PYTHON_INCLUDE_DIRS) (Required is at least version "2.7.3")
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
    ImportError: No module named numpy.distutils
    -- Found apache ant 1.8.2: /usr/bin/ant
    -- Found JNI: /usr/lib/jvm/java-6-openjdk/jre/lib/amd64/libjawt.so 
    -- Could NOT find OPENCL (missing:  OPENCL_LIBRARY OPENCL_INCLUDE_DIR) 
    CMake Error: your CXX compiler: "CMAKE_CXX_COMPILER-NOTFOUND" was not found.   Please set CMAKE_CXX_COMPILER to a valid compiler path or name.
    CMake Error: your CXX compiler: "CMAKE_CXX_COMPILER-NOTFOUND" was not found.   Please set CMAKE_CXX_COMPILER to a valid compiler path or name.
    CMake Error: your CXX compiler: "CMAKE_CXX_COMPILER-NOTFOUND" was not found.   Please set CMAKE_CXX_COMPILER to a valid compiler path or name.
    CMake Error: your CXX compiler: "CMAKE_CXX_COMPILER-NOTFOUND" was not found.   Please set CMAKE_CXX_COMPILER to a valid compiler path or name.
    CMake Error: your CXX compiler: "CMAKE_CXX_COMPILER-NOTFOUND" was not found.   Please set CMAKE_CXX_COMPILER to a valid compiler path or name.
    CMake Error: your CXX compiler: "CMAKE_CXX_COMPILER-NOTFOUND" was not found.   Please set CMAKE_CXX_COMPILER to a valid compiler path or name.
    CMake Error: your CXX compiler: "CMAKE_CXX_COMPILER-NOTFOUND" was not found.   Please set CMAKE_CXX_COMPILER to a valid compiler path or name.
    CMake Error: your CXX compiler: "CMAKE_CXX_COMPILER-NOTFOUND" was not found.   Please set CMAKE_CXX_COMPILER to a valid compiler path or name.
    CMake Error: your CXX compiler: "CMAKE_CXX_COMPILER-NOTFOUND" was not found.   Please set CMAKE_CXX_COMPILER to a valid compiler path or name.
    CMake Error: your CXX compiler: "CMAKE_CXX_COMPILER-NOTFOUND" was not found.   Please set CMAKE_CXX_COMPILER to a valid compiler path or name.
    CMake Error: your CXX compiler: "CMAKE_CXX_COMPILER-NOTFOUND" was not found.   Please set CMAKE_CXX_COMPILER to a valid compiler path or name.
    CMake Error: your CXX compiler: "CMAKE_CXX_COMPILER-NOTFOUND" was not found.   Please set CMAKE_CXX_COMPILER to a valid compiler path or name.
    CMake Error: your CXX compiler: "CMAKE_CXX_COMPILER-NOTFOUND" was not found.   Please set CMAKE_CXX_COMPILER to a valid compiler path or name.
    CMake Error: your CXX compiler: "CMAKE_CXX_COMPILER-NOTFOUND" was not found.   Please set CMAKE_CXX_COMPILER to a valid compiler path or name.
    CMake Error: your CXX compiler: "CMAKE_CXX_COMPILER-NOTFOUND" was not found.   Please set CMAKE_CXX_COMPILER to a valid compiler path or name.
    CMake Error: your CXX compiler: "CMAKE_CXX_COMPILER-NOTFOUND" was not found.   Please set CMAKE_CXX_COMPILER to a valid compiler path or name.
    CMake Error: your CXX compiler: "CMAKE_CXX_COMPILER-NOTFOUND" was not found.   Please set CMAKE_CXX_COMPILER to a valid compiler path or name.
    CMake Error: your CXX compiler: "CMAKE_CXX_COMPILER-NOTFOUND" was not found.   Please set CMAKE_CXX_COMPILER to a valid compiler path or name.
    CMake Error: your CXX compiler: "CMAKE_CXX_COMPILER-NOTFOUND" was not found.   Please set CMAKE_CXX_COMPILER to a valid compiler path or name.
    CMake Error: your CXX compiler: "CMAKE_CXX_COMPILER-NOTFOUND" was not found.   Please set CMAKE_CXX_COMPILER to a valid compiler path or name.
    CMake Error: your CXX compiler: "CMAKE_CXX_COMPILER-NOTFOUND" was not found.   Please set CMAKE_CXX_COMPILER to a valid compiler path or name.
    CMake Error: your CXX compiler: "CMAKE_CXX_COMPILER-NOTFOUND" was not found.   Please set CMAKE_CXX_COMPILER to a valid compiler path or name.
    -- 
    -- General configuration for OpenCV 2.4.6.1 =====================================
    --   Version control:               2.4.6.1-176-g1c55096
    -- 
    --   Platform:
    --     Host:                        Linux 3.5.0-37-generic x86_64
    --     CMake:                       2.8.7
    --     CMake generator:             Unix Makefiles
    --     CMake build tool:            /usr/bin/make
    --     Configuration:               Release
    -- 
    --   C/C++:
    --     Built as dynamic libs?:      NO
    --     C++ Compiler:                CMAKE_CXX_COMPILER-NOTFOUND
    --     C++ flags (Release):         
    --     C++ flags (Debug):           
    --     C Compiler:                  /usr/bin/gcc
    --     C flags (Release):           -fsigned-char -O3 -DNDEBUG 
    --     C flags (Debug):             -fsigned-char -g 
    --     Linker flags (Release):      
    --     Linker flags (Debug):        
    --     Precompiled headers:         NO
    -- 
    --   OpenCV modules:
    --     To be built:                 core imgproc flann highgui features2d calib3d ml video objdetect contrib photo legacy gpu nonfree java stitching superres ts videostab
    --     Disabled:                    world
    --     Disabled by dependency:      -
    --     Unavailable:                 androidcamera ocl python
    -- 
    --   GUI: 
    --     QT:                          NO
    --     GTK+ 2.x:                    NO
    --     GThread :                    NO
    --     GtkGlExt:                    NO
    --     OpenGL support:              NO
    -- 
    --   Media I/O: 
    --     ZLib:                        zlib (ver 1.2.7)
    --     JPEG:                        libjpeg (ver 62)
    --     PNG:                         build (ver 1.5.12)
    --     TIFF:                        build (ver 42 - 4.0.2)
    --     JPEG 2000:                   build (ver 1.900.1)
    --     OpenEXR:                     build (ver 1.7.1)
    -- 
    --   Video I/O:
    --     DC1394 1.x:                  NO
    --     DC1394 2.x:                  NO
    --     FFMPEG:                      NO
    --       codec:                     NO
    --       format:                    NO
    --       util:                      NO
    --       swscale:                   NO
    --       gentoo-style:              NO
    --     GStreamer:                   NO
    --     OpenNI:                      NO
    --     OpenNI PrimeSensor Modules:  NO
    --     PvAPI:                       NO
    --     GigEVisionSDK:               NO
    --     UniCap:                      NO
    --     UniCap ucil:                 NO
    --     V4L/V4L2:                    NO/YES
    --     XIMEA:                       NO
    --     Xine:                        NO
    -- 
    --   Other third-party libraries:
    --     Use IPP:                     NO
    --     Use Eigen:                   NO
    --     Use TBB:                     NO
    --     Use OpenMP:                  NO
    --     Use GCD                      NO
    --     Use Concurrency              NO
    --     Use C=:                      NO
    --     Use Cuda:                    NO
    --     Use OpenCL:                  NO
    -- 
    --   Python:
    --     Interpreter:                 /usr/bin/python (ver 2.7.3)
    -- 
    --   Java:
    --     ant:                         /usr/bin/ant (ver 1.8.2)
    --     JNI:                         /usr/lib/jvm/jdk1.7.0_21/include /usr/lib/jvm/jdk1.7.0_21/include/linux /usr/lib/jvm/jdk1.7.0_21/include
    --     Java tests:                  YES
    -- 
    --   Documentation:
    --     Build Documentation:         NO
    --     Sphinx:                      NO
    --     PdfLaTeX compiler:           NO
    -- 
    --   Tests and samples:
    --     Tests:                       YES
    --     Performance tests:           YES
    --     C/C++ Examples:              NO
    -- 
    --   Install path:                  /usr/local
    -- 
    --   cvconfig.h is in:              /home/user/opencv/build
    -- -----------------------------------------------------------------
    -- 
    -- Configuring incomplete, errors occurred!