opencv installation error while mingw32-make on windows

冷暖自知 提交于 2019-11-29 14:44:40

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 "opencv\sources\modules\ts\include\opencv2\ts\"

  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.

It was fixed by using TDM-gcc mingw compiler.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!