Google Test fails to compile on the default installation of MinGW
(http://www.mingw.org/):
> cmake -G "MinGW Makefiles"
> mingw32-make
...
C:/googletest/src/gtest-port.cc:202:45: error: cannot convert
'CRITICAL_SECTION* {aka _CRITICAL_SECTION*}' to '_RTL_CRITICAL_SECTION*' in
initialization
critical_section_(new CRITICAL_SECTION) {
^
C:/googletest/src/gtest-port.cc:203:48: error: cannot convert
'_RTL_CRITICAL_SECTION*' to 'LPCRITICAL_SECTION {aka _CRITICAL_SECTION*}' for
argument '1' to 'void InitializeCriticalSection(LPCRITICAL_SECTION)'
::InitializeCriticalSection(critical_section_);
^
C:/googletest/src/gtest-port.cc: In destructor
'testing::internal::Mutex::~Mutex()':
C:/googletest/src/gtest-port.cc:213:46: error: cannot convert
'_RTL_CRITICAL_SECTION*' to 'PCRITICAL_SECTION {aka _CRITICAL_SECTION*}' for
argument '1' to 'void DeleteCriticalSection(PCRITICAL_SECTION)'
::DeleteCriticalSection(critical_section_);
^
C:/googletest/src/gtest-port.cc: In member function 'void
testing::internal::Mutex::Lock()':
C:/googletest/src/gtest-port.cc:221:43: error: cannot convert
'_RTL_CRITICAL_SECTION*' to 'LPCRITICAL_SECTION {aka _CRITICAL_SECTION*}' for
argument '1' to 'void EnterCriticalSection(LPCRITICAL_SECTION)'
::EnterCriticalSection(critical_section_);
^
C:/googletest/src/gtest-port.cc: In member function 'void
testing::internal::Mutex::Unlock()':
C:/googletest/src/gtest-port.cc:231:43: error: cannot convert
'_RTL_CRITICAL_SECTION*' to 'LPCRITICAL_SECTION {aka _CRITICAL_SECTION*}' for
argument '1' to 'void LeaveCriticalSection(LPCRITICAL_SECTION)'
::LeaveCriticalSection(critical_section_);
^
C:/googletest/src/gtest-port.cc: In member function 'void
testing::internal::Mutex::ThreadSafeLazyInit()':
C:/googletest/src/gtest-port.cc:252:27: error: cannot convert
'CRITICAL_SECTION* {aka _CRITICAL_SECTION*}' to '_RTL_CRITICAL_SECTION*' in
assignment
critical_section_ = new CRITICAL_SECTION;
^
C:/googletest/src/gtest-port.cc:253:54: error: cannot convert
'_RTL_CRITICAL_SECTION*' to 'LPCRITICAL_SECTION {aka _CRITICAL_SECTION*}' for
argument '1' to 'void InitializeCriticalSection(LPCRITICAL_SECTION)'
::InitializeCriticalSection(critical_section_);
^
C:/googletest/src/gtest-port.cc: In static member function 'static void
testing::internal::ThreadLocalRegistryImpl::StartWatcherThreadFor(DWORD)':
C:/googletest/src/gtest-port.cc:455:21: error: '::OpenThread' has not been
declared
HANDLE thread = ::OpenThread(SYNCHRONIZE | THREAD_QUERY_INFORMATION,
^
Original issue reported on code.google.com by [email protected] on 19 Mar 2015 at 1:52
I get the same errors when using the same procedure. I'm using Win10, cmake 3.4.1 and mingw32-make is GNU Make 3.82.90 (built for i686-pc-mingw32).
I was receiving these exact same errors and found that I needed to upgrade my version of GCC.
I was using MinGW and MSYS on Windows and was unable to build with GCC v4.8.1 and v4.9.3. The issue was resolved when I upgraded to GCC v5.1.0 and also worked with GCC v5.3.0.
@lemtronix : How did you upgrade to GCC v5.1.0 ? My MinGW installer shows only v4.9.3 for installation?
@bofinbabu: You can find a MinGW distro with GCC v5.3.0 here: http://nuwen.net/mingw.html
I'm using GCC 6.3.0 and still getting this issues. Any advice?
I'm using GCC newest version and I get the same error.
Should be fixed now
Most helpful comment
I'm using GCC newest version and I get the same error.