2017-01-30 97 views
4

在windows 10平臺上使用mingw32-make命令進行opencv安裝時,可能最終出現以下錯誤。在windows上使用mingw32-make時出現opencv安裝錯誤

Windows版本:10 的OpenCV:3.2.0

請建議我安裝。

D:\installers\opencv\sources\modules\ts\src\ts_gtest.cpp: In constructor 'testing::internal::Mutex::Mutex()': 
D:\installers\opencv\sources\modules\ts\src\ts_gtest.cpp:8829:45: error: cannot convert 'CRITICAL_SECTION* {aka _CRITICAL_SECTION*}' to '_RTL_CRITICAL_SECTION*' in initialization 
     critical_section_(new CRITICAL_SECTION) { 
              ^
D:\installers\opencv\sources\modules\ts\src\ts_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:\installers\opencv\sources\modules\ts\src\ts_gtest.cpp: In destructor 'testing::internal::Mutex::~Mutex()': 
D:\installers\opencv\sources\modules\ts\src\ts_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:\installers\opencv\sources\modules\ts\src\ts_gtest.cpp: In member function 'void testing::internal::Mutex::Lock()': 
D:\installers\opencv\sources\modules\ts\src\ts_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:\installers\opencv\sources\modules\ts\src\ts_gtest.cpp: In member function 'void testing::internal::Mutex::Unlock()': 
D:\installers\opencv\sources\modules\ts\src\ts_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:\installers\opencv\sources\modules\ts\src\ts_gtest.cpp: In member function 'void testing::internal::Mutex::ThreadSafeLazyInit()': 
D:\installers\opencv\sources\modules\ts\src\ts_gtest.cpp:8879:27: error: cannot convert 'CRITICAL_SECTION* {aka _CRITICAL_SECTION*}' to '_RTL_CRITICAL_SECTION*' in assignment 
     critical_section_ = new CRITICAL_SECTION; 
         ^
D:\installers\opencv\sources\modules\ts\src\ts_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_); 
                ^
modules\ts\CMakeFiles\opencv_ts.dir\build.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 
CMakeFiles\Makefile2: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 
+0

訪問[本頁](http://stackoverflow.com/questions/41918477/how-to-build-opencv-3-2-0-with-mingw-on-windows?noredirect=1#comment71040237_41918477) –

+0

仍然得到相同的錯誤 –

+0

你的MinGW版本是什麼?谷歌搜索'不能轉換'CRITICAL_SECTION * {aka _CRITICAL_SECTION *}'到'_RTL_CRITICAL_SECTION *''顯示你可能需要更新MinGW和CMake。 ([示例](https://github.com/google/googletest/issues/484)) – Alex

回答

7

而試圖建立對使用的mingw32 Windows10OpenCV的3.2.0我也面臨着同樣的問題。我搜索了一下,發現類似的問題a fix on Github。它說,問題是:

MinGW的定義_CRITICAL_SECTION和_RTL_CRITICAL_SECTION作爲兩個獨立的(當量)結構,而是採用的typedef

所以,你必須增加對_CRITICAL_SECTION和_RTL_CRITICAL_SECTION和使用另一種類型定義GTEST_CRITICAL_SECTION這種typedef無論如何。

這裏是做什麼:

編輯「ts_gtest.h」這裏面「的OpenCV \來源\模塊\ TS \包括\ opencv2 \ TS \」

  1. 替換該行(可能是線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; 

 

 


    #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 

 
  • 替換這一行(大概就行3060之前,您的編輯 - 當你修改第一部分的行號會改變)
  •  
    
    
        _RTL_CRITICAL_SECTION* critical_section_; 
    
     
    

     
    
    
        GTEST_CRITICAL_SECTION* critical_section_; 
    
     
    

    這兩個變化應解決您的上述錯誤。

    相關問題