【问题标题】:opencv installation error while mingw32-make on windows在 windows 上 mingw32-make 时出现 opencv 安装错误
【发布时间】:2018-05-27 23:16:43
【问题描述】:

在 windows 10 平台上使用 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

【问题讨论】:

  • 访问THIS PAGE
  • 仍然出现同样的错误
  • 你的 MinGW 版本是多少?谷歌搜索cannot convert 'CRITICAL_SECTION* {aka _CRITICAL_SECTION*}' to '_RTL_CRITICAL_SECTION*' 显示您可能需要更新 MinGW 和 CMake。 (Example)
  • 我已经从这个站点下载了 minGw sourceforge.net/projects/mingw/files/Installer/mingw-get 版本是 mingw-get-0.6.2 而 Cmake 是 3.7.2-win64-x64。你能帮忙吗

标签: opencv mingw mingw-w64


【解决方案1】:

我在 Windows10 上尝试使用 mingw32 构建 OpenCV 3.2.0 时也遇到了同样的问题。我搜索了一下以找到类似问题的a fix on Github。它说问题是:

MinGW 将 _CRITICAL_SECTION 和 _RTL_CRITICAL_SECTION 定义为两个独立(等效)的结构,而不是使用 typedef

因此,您必须为 _CRITICAL_SECTION 和 _RTL_CRITICAL_SECTION 添加另一个 typedef GTEST_CRITICAL_SECTION 并在任一情况下使用此 typedef。

这是怎么做的:

编辑 "ts_gtest.h" 里面的 "opencv\sources\modules\ts\include\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
  1. 替换此行(可能在您编辑之前的第 3060 行 - 当您修改第一部分时,行号会发生变化)
_RTL_CRITICAL_SECTION* critical_section_;

GTEST_CRITICAL_SECTION* critical_section_;

这两项更改应该可以解决您的上述错误。

【讨论】:

    【解决方案2】:

    已通过使用 TDM-gcc mingw 编译器修复。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2017-09-27
      • 1970-01-01
      • 1970-01-01
      • 2017-03-16
      • 1970-01-01
      • 2016-02-25
      • 2017-04-19
      相关资源
      最近更新 更多