Skip to content

Failed to compile opencv-4.0.0-alpha using mingw-w64 #12642

Closed

Description

@huihut

Help

I compile opencv-4.0.0-alpha using mingw-w64.

Should I solve the following error?

Compiling Environment

  • Windows-10-64bit
  • MinGW-x64-4.8.1-release-posix-seh-rev5
  • CMake-3.12.0
  • opencv-4.0.0-alpha

Configuration

General configuration for OpenCV 4.0.0-alpha =====================================
  Version control:               unknown

  Platform:
    Timestamp:                   2018-09-25T08:37:52Z
    Host:                        Windows 10.0.17134 AMD64
    CMake:                       3.12.0
    CMake generator:             MinGW Makefiles
    CMake build tool:            E:/MinGW-w64/x64-4.8.1-release-posix-seh-rev5/mingw64/bin/mingw32-make.exe
    Configuration:               Release

  CPU/HW features:
    Baseline:                    SSE SSE2 SSE3
      requested:                 SSE3
    Dispatched code generation:  SSE4_1 SSE4_2 FP16 AVX AVX2
      requested:                 SSE4_1 SSE4_2 AVX FP16 AVX2 AVX512_SKX
      SSE4_1 (4 files):          + SSSE3 SSE4_1
      SSE4_2 (2 files):          + SSSE3 SSE4_1 POPCNT SSE4_2
      FP16 (1 files):            + SSSE3 SSE4_1 POPCNT SSE4_2 FP16 AVX
      AVX (6 files):             + SSSE3 SSE4_1 POPCNT SSE4_2 AVX
      AVX2 (10 files):           + SSSE3 SSE4_1 POPCNT SSE4_2 FP16 FMA3 AVX AVX2

  C/C++:
    Built as dynamic libs?:      YES
    C++ Compiler:                E:/MinGW-w64/x64-4.8.1-release-posix-seh-rev5/mingw64/bin/g++.exe  (ver 4.8.1)
    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 -Wno-narrowing -Wno-delete-non-virtual-dtor -Wno-comment -fdiagnostics-show-option -Wno-long-long -fomit-frame-pointer -ffunction-sections -fdata-sections  -msse -msse2 -msse3 -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 -Wno-narrowing -Wno-delete-non-virtual-dtor -Wno-comment -fdiagnostics-show-option -Wno-long-long -fomit-frame-pointer -ffunction-sections -fdata-sections  -msse -msse2 -msse3 -fvisibility=hidden -fvisibility-inlines-hidden -g  -O0 -DDEBUG -D_DEBUG
    C Compiler:                  E:/MinGW-w64/x64-4.8.1-release-posix-seh-rev5/mingw64/bin/gcc.exe
    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 -fdiagnostics-show-option -Wno-long-long -fomit-frame-pointer -ffunction-sections -fdata-sections  -msse -msse2 -msse3 -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 -fdiagnostics-show-option -Wno-long-long -fomit-frame-pointer -ffunction-sections -fdata-sections  -msse -msse2 -msse3 -fvisibility=hidden -g  -O0 -DDEBUG -D_DEBUG
    Linker flags (Release):      -Wl,--gc-sections  
    Linker flags (Debug):        -Wl,--gc-sections  
    ccache:                      NO
    Precompiled headers:         NO
    Extra dependencies:
    3rdparty dependencies:

  OpenCV modules:
    To be built:                 calib3d core dnn features2d flann highgui imgcodecs imgproc java_bindings_generator ml objdetect photo python_bindings_generator shape stitching superres ts video videoio videostab
    Disabled:                    js world
    Disabled by dependency:      -
    Unavailable:                 java python2 python3 viz
    Applications:                tests perf_tests apps
    Documentation:               NO
    Non-free algorithms:         NO

  Windows RT support:            NO

  GUI: 
    Win32 UI:                    YES
    VTK support:                 NO

  Media I/O: 
    ZLib:                        build (ver 1.2.11)
    JPEG:                        build-libjpeg-turbo (ver 1.5.3-62)
    WEBP:                        build (ver encoder: 0x020e)
    PNG:                         build (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:
    Video for Windows:           YES
    DC1394:                      NO
    FFMPEG:                      YES (prebuilt binaries)
      avcodec:                   YES (ver 58.18.100)
      avformat:                  YES (ver 58.12.100)
      avutil:                    YES (ver 56.14.100)
      swscale:                   YES (ver 5.1.100)
      avresample:                YES (ver 4.0.0)
    GStreamer:                   NO
    DirectShow:                  YES
    Media Foundation:            YES

  Parallel framework:            none

  Trace:                         YES (built-in)

  Other third-party libraries:
    Lapack:                      NO
    Eigen:                       NO
    Custom HAL:                  NO
    Protobuf:                    build (3.5.1)

  OpenCL:                        YES (no extra features)
    Include path:                E:/opencv-4.0.0-alpha/opencv-4.0.0-alpha/3rdparty/include/opencl/1.2
    Link libraries:              Dynamic load

  Python (for build):            E:/Python37-32/python.exe

  Java:                          
    ant:                         NO
    JNI:                         C:/Program Files (x86)/Java/jdk1.8.0_181/include C:/Program Files (x86)/Java/jdk1.8.0_181/include/win32 C:/Program Files (x86)/Java/jdk1.8.0_181/include
    Java wrappers:               NO
    Java tests:                  NO

  Install to:                    E:/opencv-4.0.0-alpha/opencv-4.0.0-mingw64-build/install
-----------------------------------------------------------------

Error log

......
E:\opencv-4.0.0-alpha\opencv-4.0.0-alpha\modules\videoio\src\cap_msmf.cpp: In member function 'HRESULT {anonymous}::ComPtr<T>::As({anonymous}::ComPtr<U>&) const [with U = IMF2DBuffer; T = IMFMediaBuffer; HRESULT = long int]':
E:\opencv-4.0.0-alpha\opencv-4.0.0-alpha\modules\videoio\src\cap_msmf.cpp:172:5: error: control reaches end of non-void function [-Werror=return-type]
     }
     ^
E:\opencv-4.0.0-alpha\opencv-4.0.0-alpha\modules\videoio\src\cap_msmf.cpp: In member function 'T* {anonymous}::ComPtr<T>::operator->() const [with T = IMF2DBuffer]':
E:\opencv-4.0.0-alpha\opencv-4.0.0-alpha\modules\videoio\src\cap_msmf.cpp:149:5: error: control reaches end of non-void function [-Werror=return-type]
     }
     ^
E:\opencv-4.0.0-alpha\opencv-4.0.0-alpha\modules\videoio\src\cap_msmf.cpp: In member function 'T* {anonymous}::ComPtr<T>::operator->() const [with T = IMFMediaBuffer]':
E:\opencv-4.0.0-alpha\opencv-4.0.0-alpha\modules\videoio\src\cap_msmf.cpp:149:5: error: control reaches end of non-void function [-Werror=return-type]
     }
     ^
E:\opencv-4.0.0-alpha\opencv-4.0.0-alpha\modules\videoio\src\cap_msmf.cpp: In member function 'T* {anonymous}::ComPtr<T>::operator->() const [with T = IMFSinkWriter]':
E:\opencv-4.0.0-alpha\opencv-4.0.0-alpha\modules\videoio\src\cap_msmf.cpp:149:5: error: control reaches end of non-void function [-Werror=return-type]
     }
     ^
E:\opencv-4.0.0-alpha\opencv-4.0.0-alpha\modules\videoio\src\cap_msmf.cpp: In member function 'T* {anonymous}::ComPtr<T>::Get() const [with T = IMFMediaBuffer]':
E:\opencv-4.0.0-alpha\opencv-4.0.0-alpha\modules\videoio\src\cap_msmf.cpp:158:5: error: control reaches end of non-void function [-Werror=return-type]
     }
     ^
cc1plus.exe: some warnings being treated as errors
modules\videoio\CMakeFiles\opencv_videoio.dir\build.make:188: recipe for target 'modules/videoio/CMakeFiles/opencv_videoio.dir/src/cap_msmf.cpp.obj' failed
mingw32-make[2]: *** [modules/videoio/CMakeFiles/opencv_videoio.dir/src/cap_msmf.cpp.obj] Error 1
CMakeFiles\Makefile2:2556: recipe for target 'modules/videoio/CMakeFiles/opencv_videoio.dir/all' failed
mingw32-make[1]: *** [modules/videoio/CMakeFiles/opencv_videoio.dir/all] Error 2
mingw32-make[1]: *** Waiting for unfinished jobs....
[ 58%] Linking CXX shared library ..\..\bin\libopencv_dnn400.dll
[ 59%] Built target opencv_dnn
Makefile:161: recipe for target 'all' failed
mingw32-make: *** [all] Error 2

Activity

  1. changed the title [-]Failed to compile opencv-4.0.0-alpha using Mingw-64[/-] [+]Failed to compile opencv-4.0.0-alpha using mingw-w64[/+] on Sep 25, 2018
  2. berak commented on Sep 25, 2018

    @berak
    Contributor

    mingw can't compile the MSMF capture code, you have to disable it:

    cmake -DWITH_MSMF=OFF
    
  3. huihut commented on Sep 25, 2018

    @huihut
    ContributorAuthor

    @berak Thanks, that error was solved, but I encountered another error: 'M_PI' was not declared in this scope

    [ 86%] Building CXX object modules/calib3d/CMakeFiles/opencv_calib3d.dir/src/chessboard.cpp.obj
    In file included from E:\opencv-4.0.0-alpha\opencv-4.0.0-alpha\modules\calib3d\src\chessboard.cpp:7:0:
    E:\opencv-4.0.0-alpha\opencv-4.0.0-alpha\modules\calib3d\src\chessboard.hpp: In constructor 'cv::details::FastX::Parameters::Parameters()':
    E:\opencv-4.0.0-alpha\opencv-4.0.0-alpha\modules\calib3d\src\chessboard.hpp:35:36: error: 'M_PI' was not declared in this scope
                     resolution = float(M_PI*0.25);
                                        ^
    E:\opencv-4.0.0-alpha\opencv-4.0.0-alpha\modules\calib3d\src\chessboard.cpp: At global scope:
    E:\opencv-4.0.0-alpha\opencv-4.0.0-alpha\modules\calib3d\src\chessboard.cpp:25:42: error: 'M_PI' was not declared in this scope
     const float MAX_ANGLE = float(48.0/180.0*M_PI);          // max angle between line segments supposed to be straight
                                              ^
    E:\opencv-4.0.0-alpha\opencv-4.0.0-alpha\modules\calib3d\src\chessboard.cpp:26:48: error: 'M_PI' was not declared in this scope
     const float MIN_COS_ANGLE = float(cos(35.0/180*M_PI));   // min cos angle between board edges
                                                    ^
    E:\opencv-4.0.0-alpha\opencv-4.0.0-alpha\modules\calib3d\src\chessboard.cpp:29:35: error: 'M_PI' was not declared in this scope
     const float RAD2DEG = float(180.0/M_PI);
                                       ^
    E:\opencv-4.0.0-alpha\opencv-4.0.0-alpha\modules\calib3d\src\chessboard.cpp: In function 'int cv::details::testPointSymmetry(cv::Mat, cv::Point2f, float, float)':
    E:\opencv-4.0.0-alpha\opencv-4.0.0-alpha\modules\calib3d\src\chessboard.cpp:217:33: error: 'M_PI' was not declared in this scope
         for(double angle=0;angle <= M_PI;angle+=M_PI*0.1)
                                     ^
    E:\opencv-4.0.0-alpha\opencv-4.0.0-alpha\modules\calib3d\src\chessboard.cpp: In member function 'void cv::details::FastX::rotate(float, const cv::Mat&, cv::Size, cv::Mat&) const':
    E:\opencv-4.0.0-alpha\opencv-4.0.0-alpha\modules\calib3d\src\chessboard.cpp:287:110: error: 'M_PI' was not declared in this scope
             cv::Mat m = cv::getRotationMatrix2D(cv::Point2f(float(img.cols*0.5),float(img.rows*0.5)),float(angle/M_PI*180),1);
                                                                                                                  ^
    E:\opencv-4.0.0-alpha\opencv-4.0.0-alpha\modules\calib3d\src\chessboard.cpp: In member function 'std::vector<std::vector<float> > cv::details::FastX::calcAngles(const std::vector<cv::Mat>&, std::vector<cv::KeyPoint>&) const':
    E:\opencv-4.0.0-alpha\opencv-4.0.0-alpha\modules\calib3d\src\chessboard.cpp:393:30: error: 'M_PI' was not declared in this scope
         float resolution = float(M_PI/channels);
                                  ^
    E:\opencv-4.0.0-alpha\opencv-4.0.0-alpha\modules\calib3d\src\chessboard.cpp: In member function 'void cv::details::FastX::detectImpl(const cv::Mat&, std::vector<cv::Mat>&, std::vector<cv::Mat>&, const cv::Mat&) const':
    E:\opencv-4.0.0-alpha\opencv-4.0.0-alpha\modules\calib3d\src\chessboard.cpp:631:30: error: 'M_PI' was not declared in this scope
             int num = int(0.5001*M_PI/parameters.resolution);
                                  ^
    E:\opencv-4.0.0-alpha\opencv-4.0.0-alpha\modules\calib3d\src\chessboard.cpp: In member function 'void cv::details::Ellipse::draw(cv::InputOutputArray, const Scalar&) const':
    E:\opencv-4.0.0-alpha\opencv-4.0.0-alpha\modules\calib3d\src\chessboard.cpp:721:43: error: 'M_PI' was not declared in this scope
         cv::ellipse(img,center,axes,360-angle/M_PI*180,0,360,color);
                                               ^
    E:\opencv-4.0.0-alpha\opencv-4.0.0-alpha\modules\calib3d\src\chessboard.cpp: In static member function 'static float cv::details::Chessboard::Board::findMaxPoint(cv::flann::Index&, const cv::Mat&, const cv::details::Ellipse&, float, float, cv::Point2f&)':
    E:\opencv-4.0.0-alpha\opencv-4.0.0-alpha\modules\calib3d\src\chessboard.cpp:1541:17: error: 'M_PI' was not declared in this scope
             if(a1 > M_PI*0.5)
                     ^
    E:\opencv-4.0.0-alpha\opencv-4.0.0-alpha\modules\calib3d\src\chessboard.cpp:1543:16: error: 'M_PI' was not declared in this scope
             if(a2> M_PI*0.5)
                    ^
    E:\opencv-4.0.0-alpha\opencv-4.0.0-alpha\modules\calib3d\src\chessboard.cpp: In static member function 'static bool cv::details::Chessboard::Board::estimateSearchArea(const Point2f&, const Point2f&, const Point2f&, float, cv::details::Ellipse&, const Point2f*)':
    E:\opencv-4.0.0-alpha\opencv-4.0.0-alpha\modules\calib3d\src\chessboard.cpp:1787:28: error: 'M_PI' was not declared in this scope
             angle = float(2.0F*M_PI-angle);
                                ^
    E:\opencv-4.0.0-alpha\opencv-4.0.0-alpha\modules\calib3d\src\chessboard.cpp: In member function 'void cv::details::Chessboard::findKeyPoints(const cv::Mat&, std::vector<cv::KeyPoint>&, std::vector<cv::Mat>&, std::vector<std::vector<float> >&, const cv::Mat&) const':
    E:\opencv-4.0.0-alpha\opencv-4.0.0-alpha\modules\calib3d\src\chessboard.cpp:2793:29: error: 'M_PI' was not declared in this scope
         para.resolution = float(M_PI*0.25);   // this gives the best results taking interpolation into account
                                 ^
    E:\opencv-4.0.0-alpha\opencv-4.0.0-alpha\modules\calib3d\src\chessboard.cpp: In member function 'cv::Mat cv::details::Chessboard::buildData(const std::vector<cv::KeyPoint>&) const':
    E:\opencv-4.0.0-alpha\opencv-4.0.0-alpha\modules\calib3d\src\chessboard.cpp:2844:30: error: 'M_PI' was not declared in this scope
             (*val++) = float(2.0*M_PI-iter->angle/180.0*M_PI);
                                  ^
    E:\opencv-4.0.0-alpha\opencv-4.0.0-alpha\modules\calib3d\src\chessboard.cpp: In member function 'std::vector<cv::KeyPoint> cv::details::Chessboard::getInitialPoints(cv::flann::Index&, const cv::Mat&, const cv::KeyPoint&, float, float, float) const':
    E:\opencv-4.0.0-alpha\opencv-4.0.0-alpha\modules\calib3d\src\chessboard.cpp:2874:25: error: 'M_PI' was not declared in this scope
             if(angle_temp > M_PI*0.5)
                             ^
    E:\opencv-4.0.0-alpha\opencv-4.0.0-alpha\modules\calib3d\src\chessboard.cpp:2879:29: error: 'M_PI' was not declared in this scope
                 if(angle_temp > M_PI*0.5)
                                 ^
    modules\calib3d\CMakeFiles\opencv_calib3d.dir\build.make:137: recipe for target 'modules/calib3d/CMakeFiles/opencv_calib3d.dir/src/chessboard.cpp.obj' failed
    mingw32-make[2]: *** [modules/calib3d/CMakeFiles/opencv_calib3d.dir/src/chessboard.cpp.obj] Error 1
    CMakeFiles\Makefile2:3018: recipe for target 'modules/calib3d/CMakeFiles/opencv_calib3d.dir/all' failed
    mingw32-make[1]: *** [modules/calib3d/CMakeFiles/opencv_calib3d.dir/all] Error 2
    Makefile:161: recipe for target 'all' failed
    mingw32-make: *** [all] Error 2
    
  4. berak commented on Sep 25, 2018

    @berak
    Contributor

    change it to CV_PI .
    later mingw versions (4.8.1 is very old) do have M_PI, so maybe update it ?

  5. huihut commented on Sep 25, 2018

    @huihut
    ContributorAuthor

    @berak Thanks, I succeeded in compiling opencv through modifying it.

    Which branch(tree) should I make a pr?

  6. berak commented on Sep 25, 2018

    @berak
    Contributor

    if so, 3.4.

  7. huihut commented on Sep 25, 2018

    @huihut
    ContributorAuthor

    I modified chessboard.cpp, chessboard.hpp and test_chesscorners.cpp at master, because 3.4 does not have chessboard.cpp and chessboard.hpp

    And I can compile because I modified these three files.

    #12645

  8. berak commented on Sep 25, 2018

    @berak
    Contributor

    apologies, i was wrong about the branch, then, use the same you have (4.0.0-alpha).

  9. huihut commented on Sep 25, 2018

    @huihut
    ContributorAuthor

    emmm, 4.0.0-alpha is a tag, I can't change it. What should I do?
    _20180926013210

  10. berak commented on Sep 25, 2018

    @berak
    Contributor

    uff. ofc.
    but again, your pr is all looking fine. why not leave everything "as is" now ?

  11. huihut commented on Sep 26, 2018

    @huihut
    ContributorAuthor

    OK, then I won't be PR again.

  12. 1iver commented on Mar 10, 2022

    @1iver

    Again, OpenCV 4.5.5, the same kind problem appears, what a terrible experience.

  13. berak commented on Mar 10, 2022

    @berak
    Contributor

    @1iver -- which "same problem", please ?

  14. 1iver commented on Mar 11, 2022

    @1iver

    opencv_4_5_5_mingw_8_1
    Thanks, @berak This is the first error. Build progress failed when compiling cap_msmf.cpp. It has something to do with these files "mfplay.h", "evr.h", "cap_msmf.cpp". From this post, I thought it was possible to build MXMF using mingw while I end in failure.

  15. berak commented on Mar 11, 2022

    @berak
    Contributor

    again, mingw does not have the needed headers / code for MSMF,
    that's why you still have to disable it when building the opencv libs:

    cmake -DWITH_MSMF=OFF
    
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions