Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build Errors on MinGW #789

Closed
jon-whit opened this issue May 26, 2016 · 4 comments
Closed

Build Errors on MinGW #789

jon-whit opened this issue May 26, 2016 · 4 comments

Comments

@jon-whit
Copy link

I am trying to build Google Test, but I am getting build errors in the gtest-port.cc file.

Specs
MSYS GNU Make 3.81
g++ (GCC) 3.4.4 (msys special)

> C:\MinGW\msys\1.0\bin\make all
g++ -isystem ../include -g -Wall -Wextra -pthread -c ../samples/sample1.cc
g++ -isystem ../include -g -Wall -Wextra -pthread -c ../samples/sample1_unittest
.cc
g++ -isystem ../include -I.. -g -Wall -Wextra -pthread -c \
            ../src/gtest-all.cc
In file included from ../src/gtest-all.cc:45:0:
../src/gtest-port.cc: In constructor 'testing::internal::Mutex::Mutex()':
../src/gtest-port.cc:242:45: error: cannot convert 'CRITICAL_SECTION* {aka _CRIT
ICAL_SECTION*}' to '_RTL_CRITICAL_SECTION*' in initialization
       critical_section_(new CRITICAL_SECTION) {
                                             ^
../src/gtest-port.cc:243:48: error: cannot convert '_RTL_CRITICAL_SECTION*' to '
LPCRITICAL_SECTION {aka _CRITICAL_SECTION*}' for argument '1' to 'void Initializ
eCriticalSection(LPCRITICAL_SECTION)'
   ::InitializeCriticalSection(critical_section_);
                                                ^
../src/gtest-port.cc: In destructor 'testing::internal::Mutex::~Mutex()':
../src/gtest-port.cc:253:46: error: cannot convert '_RTL_CRITICAL_SECTION*' to '
PCRITICAL_SECTION {aka _CRITICAL_SECTION*}' for argument '1' to 'void DeleteCrit
icalSection(PCRITICAL_SECTION)'
     ::DeleteCriticalSection(critical_section_);
                                              ^
../src/gtest-port.cc: In member function 'void testing::internal::Mutex::Lock()'
:
../src/gtest-port.cc:261:43: error: cannot convert '_RTL_CRITICAL_SECTION*' to '
LPCRITICAL_SECTION {aka _CRITICAL_SECTION*}' for argument '1' to 'void EnterCrit
icalSection(LPCRITICAL_SECTION)'
   ::EnterCriticalSection(critical_section_);
                                           ^
../src/gtest-port.cc: In member function 'void testing::internal::Mutex::Unlock(
)':
../src/gtest-port.cc:271:43: error: cannot convert '_RTL_CRITICAL_SECTION*' to '
LPCRITICAL_SECTION {aka _CRITICAL_SECTION*}' for argument '1' to 'void LeaveCrit
icalSection(LPCRITICAL_SECTION)'
   ::LeaveCriticalSection(critical_section_);
                                           ^
../src/gtest-port.cc: In member function 'void testing::internal::Mutex::ThreadS
afeLazyInit()':
../src/gtest-port.cc:292:27: error: cannot convert 'CRITICAL_SECTION* {aka _CRIT
ICAL_SECTION*}' to '_RTL_CRITICAL_SECTION*' in assignment
         critical_section_ = new CRITICAL_SECTION;
                           ^
../src/gtest-port.cc:293:54: error: cannot convert '_RTL_CRITICAL_SECTION*' to '
LPCRITICAL_SECTION {aka _CRITICAL_SECTION*}' for argument '1' to 'void Initializ
eCriticalSection(LPCRITICAL_SECTION)'
         ::InitializeCriticalSection(critical_section_);
                                                      ^
../src/gtest-port.cc: In static member function 'static void testing::internal::
ThreadLocalRegistryImpl::StartWatcherThreadFor(DWORD)':
../src/gtest-port.cc:495:21: error: '::OpenThread' has not been declared
     HANDLE thread = ::OpenThread(SYNCHRONIZE | THREAD_QUERY_INFORMATION,
                     ^
make: *** [gtest-all.o] Error 1

Is there an easy fix to this. I have been lead down many rabbit holes trying to fix it.

@Draqun
Copy link

Draqun commented May 27, 2016

I have this same error. I changed MinGW version but it does not help. Maybe I put here how I create makefile


$  cmake -G "MSYS Makefiles" -Dgtest_build_samples=ON -Dgmock_build_samples=ON -Dgtest_build_tests=ON -Dgmock_build_tests=ON
-- The CXX compiler identification is GNU 4.9.3
-- The C compiler identification is GNU 4.9.3
-- Check for working CXX compiler: C:/MinGW/bin/g++.exe
-- Check for working CXX compiler: C:/MinGW/bin/g++.exe -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Check for working C compiler: C:/MinGW/bin/gcc.exe
-- Check for working C compiler: C:/MinGW/bin/gcc.exe -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Found PythonInterp: C:/Python27/python.exe (found version "2.7.11")
-- Looking for pthread.h
-- Looking for pthread.h - not found
-- Found Threads: TRUE
-- Configuring done
-- Generating done
CMake Warning:
  Manually-specified variables were not used by the project:

    gmock_build_samples
    gmock_build_tests


-- Build files have been written to: D:/googletest/googletest

@jon-whit
Copy link
Author

Any googletest developers addressed this issue?

@KindDragon
Copy link
Contributor

Duplicate of #606. Please close

@jon-whit
Copy link
Author

@KindDragon thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants