Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
303 views
in Technique[技术] by (71.8m points)

mingw - opencv installation error while mingw32-make on windows

opencv installation using mingw32-make command in windows 10 platform, then likely end up in getting the below error.

Windows version : 10 OpenCv:3.2.0

Please suggest me in installing.

D:installersopencvsourcesmodulesssrcs_gtest.cpp: In constructor 'testing::internal::Mutex::Mutex()':
D:installersopencvsourcesmodulesssrcs_gtest.cpp:8829:45: error: cannot convert 'CRITICAL_SECTION* {aka _CRITICAL_SECTION*}' to '_RTL_CRITICAL_SECTION*' in initialization
       critical_section_(new CRITICAL_SECTION) {
                                             ^
D:installersopencvsourcesmodulesssrcs_gtest.cpp:8830:48: error: cannot convert '_RTL_CRITICAL_SECTION*' to 'LPCRITICAL_SECTION {aka _CRITICAL_SECTION*}' for argument '1' to 'void InitializeCriticalSection(LPCRITICAL_SECTION)'
   ::InitializeCriticalSection(critical_section_);
                                                ^
D:installersopencvsourcesmodulesssrcs_gtest.cpp: In destructor 'testing::internal::Mutex::~Mutex()':
D:installersopencvsourcesmodulesssrcs_gtest.cpp:8840:46: error: cannot convert '_RTL_CRITICAL_SECTION*' to 'PCRITICAL_SECTION {aka _CRITICAL_SECTION*}' for argument '1' to 'void DeleteCriticalSection(PCRITICAL_SECTION)'
     ::DeleteCriticalSection(critical_section_);
                                              ^
D:installersopencvsourcesmodulesssrcs_gtest.cpp: In member function 'void testing::internal::Mutex::Lock()':
D:installersopencvsourcesmodulesssrcs_gtest.cpp:8848:43: error: cannot convert '_RTL_CRITICAL_SECTION*' to 'LPCRITICAL_SECTION {aka _CRITICAL_SECTION*}' for argument '1' to 'void EnterCriticalSection(LPCRITICAL_SECTION)'
   ::EnterCriticalSection(critical_section_);
                                           ^
D:installersopencvsourcesmodulesssrcs_gtest.cpp: In member function 'void testing::internal::Mutex::Unlock()':
D:installersopencvsourcesmodulesssrcs_gtest.cpp:8858:43: error: cannot convert '_RTL_CRITICAL_SECTION*' to 'LPCRITICAL_SECTION {aka _CRITICAL_SECTION*}' for argument '1' to 'void LeaveCriticalSection(LPCRITICAL_SECTION)'
   ::LeaveCriticalSection(critical_section_);
                                           ^
D:installersopencvsourcesmodulesssrcs_gtest.cpp: In member function 'void testing::internal::Mutex::ThreadSafeLazyInit()':
D:installersopencvsourcesmodulesssrcs_gtest.cpp:8879:27: error: cannot convert 'CRITICAL_SECTION* {aka _CRITICAL_SECTION*}' to '_RTL_CRITICAL_SECTION*' in assignment
         critical_section_ = new CRITICAL_SECTION;
                           ^
D:installersopencvsourcesmodulesssrcs_gtest.cpp:8880:54: error: cannot convert '_RTL_CRITICAL_SECTION*' to 'LPCRITICAL_SECTION {aka _CRITICAL_SECTION*}' for argument '1' to 'void InitializeCriticalSection(LPCRITICAL_SECTION)'
         ::InitializeCriticalSection(critical_section_);
                                                      ^
modulessCMakeFilesopencv_ts.diruild.make:237: recipe for target 'modules/ts/CMakeFiles/opencv_ts.dir/src/ts_gtest.cpp.obj' failed
mingw32-make[2]: *** [modules/ts/CMakeFiles/opencv_ts.dir/src/ts_gtest.cpp.obj] Error 1
CMakeFilesMakefile2:5379: recipe for target 'modules/ts/CMakeFiles/opencv_ts.dir/all' failed
mingw32-make[1]: *** [modules/ts/CMakeFiles/opencv_ts.dir/all] Error 2
Makefile:159: recipe for target 'all' failed
mingw32-make: *** [all] Error 2
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

I also faced the same problem while trying to build OpenCV 3.2.0 using mingw32 on Windows10. I searched a bit to find a fix on Github for similar problem. It said the problem was:

MinGW defined _CRITICAL_SECTION and _RTL_CRITICAL_SECTION as two separate (equivalent) structs, instead of using typedef

So, you have to add another typedef GTEST_CRITICAL_SECTION for _CRITICAL_SECTION and _RTL_CRITICAL_SECTION and use this typedef for either case.

Here is what to do :

Edit "ts_gtest.h" which is inside "opencvsourcesmodulessincludeopencv2s"

  1. Replace this line (probably line 723)


    // assuming CRITICAL_SECTION is a typedef of _RTL_CRITICAL_SECTION.
    // This assumption is verified by
    // WindowsTypesTest.CRITICAL_SECTIONIs_RTL_CRITICAL_SECTION.
    struct _RTL_CRITICAL_SECTION;


with



    #if GTEST_OS_WINDOWS_MINGW
        // MinGW defined _CRITICAL_SECTION and _RTL_CRITICAL_SECTION as two
        // separate (equivalent) structs, instead of using typedef
        typedef struct _CRITICAL_SECTION GTEST_CRITICAL_SECTION;
    #else
        // Assume CRITICAL_SECTION is a typedef of _RTL_CRITICAL_SECTION.
        // This assumption is verified by
        // WindowsTypesTest.CRITICAL_SECTIONIs_RTL_CRITICAL_SECTION
        typedef struct _RTL_CRITICAL_SECTION GTEST_CRITICAL_SECTION;
    #endif


  1. Replace this line (probably on line 3060 before your edit - line number would have changed as you modified first part)


    _RTL_CRITICAL_SECTION* critical_section_;


with



    GTEST_CRITICAL_SECTION* critical_section_;


These two changes should fix your above error.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...