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 error by using cmake on mingw in windows #1051

Closed
demiaowu opened this issue Mar 24, 2017 · 2 comments
Closed

build error by using cmake on mingw in windows #1051

demiaowu opened this issue Mar 24, 2017 · 2 comments

Comments

@demiaowu
Copy link

cmake version 3.8.0-rc2
googletest 1.8.0

Detail error infromation as follows.
$ cmake -G "MinGW Makefiles" -DCMAKE_CXX_FLAGS=-std=gnu++11

W/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
-- Could NOT find PythonInterp (missing: PYTHON_EXECUTABLE)
-- Looking for pthread.h
-- Looking for pthread.h - found
--Looking for pthread_create
-- Looking for pthread_create - not found
-- Looking for pthread_create in pthreads
-- Looking for pthread_create in pthreads - not found
-- Looking for pthread_create in pthread
-- Looking for pthread_create in pthread - found
-- Found Threads: TRUE
-- Configuring done
-- Generating done
-- Build files have been written to: F:/Libs/googletest

$ mingw32-make

Scanning dependencies of target gtest
[ 25%] Building CXX object CMakeFiles/gtest.dir/src/gtest-all.cc.obj
In file included from F:/Libs/googletest/include/gtest/internal/gtest-internal.h:40:0,
from F:/Libs/googletest/include/gtest/gtest.h:58,
from F:\Libs\googletest\src\gtest-all.cc:39:
F:/Libs/googletest/include/gtest/internal/gtest-port.h:1782:3: error: 'AutoHandle' does not name a type
AutoHandle thread_;
^
F:/Libs/googletest/include/gtest/internal/gtest-port.h: In function 'int testing::internal::posix::StrCaseCmp(const char*, const char*)':
F:/Libs/googletest/include/gtest/internal/gtest-port.h:2318:25: error: 'stricmp' was not declared in this scope
return stricmp(s1, s2);
^
In file included from F:\Libs\googletest\src\gtest-all.cc:43:0:
F:/Libs/googletest/src/gtest-death-test.cc: At global scope:
F:/Libs/googletest/src/gtest-death-test.cc:637:3: error: 'AutoHandle' does not name a type
AutoHandle write_handle
;
^
F:/Libs/googletest/src/gtest-death-test.cc:639:3: error: 'AutoHandle' does not name a type
AutoHandle child_handle
;
^
F:/Libs/googletest/src/gtest-death-test.cc:644:3: error: 'AutoHandle' does not name a type
AutoHandle event_handle_;
^
F:/Libs/googletest/src/gtest-death-test.cc: In member function 'virtual int testing::internal::WindowsDeathTest::Wait()':
F:/Libs/googletest/src/gtest-death-test.cc:656:36: error: 'child_handle_' was not declared in this scope
const HANDLE wait_handles[2] = { child_handle_.Get(), event_handle_.Get() };
^
F:/Libs/googletest/src/gtest-death-test.cc:656:57: error: 'event_handle_' was not declared in this scope
const HANDLE wait_handles[2] = { child_handle_.Get(), event_handle_.Get() };
^
F:/Libs/googletest/src/gtest-death-test.cc:670:3: error: 'write_handle_' was not declared in this scope
write_handle_.Reset();
^
F:/Libs/googletest/src/gtest-death-test.cc: In member function 'virtual testing::internal::DeathTest::TestRole testing::internal::WindowsDeathTest::AssumeRole()':
F:/Libs/googletest/src/gtest-death-test.cc:720:3: error: 'write_handle_' was not declared in this scope
write_handle_.Reset(write_handle);
^
F:/Libs/googletest/src/gtest-death-test.cc:721:3: error: 'event_handle_' was not declared in this scope
event_handle_.Reset(::CreateEvent(
^
F:/Libs/googletest/src/gtest-death-test.cc:777:3: error: 'child_handle_' was not declared in this scope
child_handle_.Reset(process_info.hProcess);
^
F:/Libs/googletest/src/gtest-death-test.cc: In function 'int testing::internal::GetStatusFileDescriptor(unsigned int, size_t, size_t)':
F:/Libs/googletest/src/gtest-death-test.cc:1230:3: error: 'AutoHandle' was not declared in this scope
AutoHandle parent_process_handle(::OpenProcess(PROCESS_DUP_HANDLE,
^
F:/Libs/googletest/src/gtest-death-test.cc:1233:7: error: 'parent_process_handle' was not declared in this scope
if (parent_process_handle.Get() == INVALID_HANDLE_VALUE) {
^
F:/Libs/googletest/src/gtest-death-test.cc:1249:26: error: 'parent_process_handle' was not declared in this scope
if (!::DuplicateHandle(parent_process_handle.Get(), write_handle,
^
F:/Libs/googletest/src/gtest-death-test.cc:1264:26: error: 'parent_process_handle' was not declared in this scope
if (!::DuplicateHandle(parent_process_handle.Get(), event_handle,
^
In file included from F:\Libs\googletest\src\gtest-all.cc:45:0:
F:/Libs/googletest/src/gtest-port.cc: In function 'void testing::internal::SleepMilliseconds(int)':
F:/Libs/googletest/src/gtest-port.cc:179:6: error: redefinition of 'void testing::internal::SleepMilliseconds(int)'
void SleepMilliseconds(int n) {
^
In file included from F:/Libs/googletest/include/gtest/internal/gtest-internal.h:40:0,
from F:/Libs/googletest/include/gtest/gtest.h:58,
from F:\Libs\googletest\src\gtest-all.cc:39:
F:/Libs/googletest/include/gtest/internal/gtest-port.h:1448:13: note: 'void testing::internal::SleepMilliseconds(int)' previously defined here
inline void SleepMilliseconds(int n) {
^
In file included from F:\Libs\googletest\src\gtest-all.cc:45:0:
F:/Libs/googletest/src/gtest-port.cc: At global scope:
F:/Libs/googletest/src/gtest-port.cc:183:1: error: 'AutoHandle' does not name a type
AutoHandle::AutoHandle()
^
F:/Libs/googletest/src/gtest-port.cc:186:1: error: 'AutoHandle' does not name a type
AutoHandle::AutoHandle(Handle handle)
^
F:/Libs/googletest/src/gtest-port.cc:189:1: error: 'AutoHandle' does not name a type
AutoHandle::~AutoHandle() {
^
F:/Libs/googletest/src/gtest-port.cc:193:1: error: 'AutoHandle' does not name a type
AutoHandle::Handle AutoHandle::Get() const {
^
F:/Libs/googletest/src/gtest-port.cc:197:6: error: 'AutoHandle' has not been declared
void AutoHandle::Reset() {
^
F:/Libs/googletest/src/gtest-port.cc: In function 'void testing::internal::Reset()':
F:/Libs/googletest/src/gtest-port.cc:198:29: error: too many arguments to function 'void testing::internal::Reset()'
Reset(INVALID_HANDLE_VALUE);
^
F:/Libs/googletest/src/gtest-port.cc:197:6: note: declared here
void AutoHandle::Reset() {
^
F:/Libs/googletest/src/gtest-port.cc: At global scope:
F:/Libs/googletest/src/gtest-port.cc:201:6: error: 'AutoHandle' has not been declared
void AutoHandle::Reset(HANDLE handle) {
^
F:/Libs/googletest/src/gtest-port.cc: In function 'void testing::internal::Reset(HANDLE)':
F:/Libs/googletest/src/gtest-port.cc:203:7: error: 'handle_' was not declared in this scope
if (handle_ != handle) {
^
F:/Libs/googletest/src/gtest-port.cc:204:21: error: 'IsCloseable' was not declared in this scope
if (IsCloseable()) {
^
In file included from F:/Libs/googletest/include/gtest/internal/gtest-internal.h:40:0,
from F:/Libs/googletest/include/gtest/gtest.h:58,
from F:\Libs\googletest\src\gtest-all.cc:39:
F:/Libs/googletest/src/gtest-port.cc:209:31: error: 'IsCloseable' was not declared in this scope
GTEST_CHECK_(!IsCloseable())
^
F:/Libs/googletest/include/gtest/internal/gtest-port.h:1297:37: note: in definition of macro 'GTEST_CHECK_'
if (::testing::internal::IsTrue(condition))
^
In file included from F:\Libs\googletest\src\gtest-all.cc:45:0:
F:/Libs/googletest/src/gtest-port.cc: At global scope:
F:/Libs/googletest/src/gtest-port.cc:215:6: error: 'AutoHandle' has not been declared
bool AutoHandle::IsCloseable() const {
^
F:/Libs/googletest/src/gtest-port.cc:215:32: error: non-member function 'bool testing::internal::IsCloseable()' cannot have cv-qualifier
bool AutoHandle::IsCloseable() const {
^
F:/Libs/googletest/src/gtest-port.cc: In function 'bool testing::internal::IsCloseable()':
F:/Libs/googletest/src/gtest-port.cc:218:10: error: 'handle_' was not declared in this scope
return handle_ != NULL && handle_ != INVALID_HANDLE_VALUE;
^
F:/Libs/googletest/src/gtest-port.cc: At global scope:
F:/Libs/googletest/src/gtest-port.cc:221:1: error: redefinition of 'testing::internal::Notification::Notification()'
Notification::Notification()
^
In file included from F:/Libs/googletest/include/gtest/internal/gtest-internal.h:40:0,
from F:/Libs/googletest/include/gtest/gtest.h:58,
from F:\Libs\googletest\src\gtest-all.cc:39:
F:/Libs/googletest/include/gtest/internal/gtest-port.h:1470:3: note: 'testing::internal::Notification::Notification()' previously defined here
Notification() : notified_(false) {
^
In file included from F:\Libs\googletest\src\gtest-all.cc:45:0:
F:/Libs/googletest/src/gtest-port.cc:229:6: error: redefinition of 'void testing::internal::Notification::Notify()'
void Notification::Notify() {
^
In file included from F:/Libs/googletest/include/gtest/internal/gtest-internal.h:40:0,
from F:/Libs/googletest/include/gtest/gtest.h:58,
from F:\Libs\googletest\src\gtest-all.cc:39:
F:/Libs/googletest/include/gtest/internal/gtest-port.h:1479:8: note: 'void testing::internal::Notification::Notify()' previously defined here
void Notify() {
^
In file included from F:\Libs\googletest\src\gtest-all.cc:45:0:
F:/Libs/googletest/src/gtest-port.cc:233:6: error: redefinition of 'void testing::internal::Notification::WaitForNotification()'
void Notification::WaitForNotification() {
^
In file included from F:/Libs/googletest/include/gtest/internal/gtest-internal.h:40:0,
from F:/Libs/googletest/include/gtest/gtest.h:58,
from F:\Libs\googletest\src\gtest-all.cc:39:
F:/Libs/googletest/include/gtest/internal/gtest-port.h:1487:8: note: 'void testing::internal::Notification::WaitForNotification()' previously defined here
void WaitForNotification() {
^
In file included from F:\Libs\googletest\src\gtest-all.cc:45:0:
F:/Libs/googletest/src/gtest-port.cc: In constructor 'testing::internal::Mutex::Mutex()':
F:/Libs/googletest/src/gtest-port.cc:242:45: error: cannot convert 'CRITICAL_SECTION* {aka _CRITICAL_SECTION*}' to 'RTL_CRITICAL_SECTION*' in initialization
critical_section
(new CRITICAL_SECTION) {
^
F:/Libs/googletest/src/gtest-port.cc:243:48: error: cannot convert 'RTL_CRITICAL_SECTION*' to 'LPCRITICAL_SECTION {aka CRITICAL_SECTION*}' for argument '1' to 'void InitializeCriticalSection(LPCRITICAL_SECTION)'
::InitializeCriticalSection(critical_section
);
^
F:/Libs/googletest/src/gtest-port.cc: In destructor 'testing::internal::Mutex::~Mutex()':
F:/Libs/googletest/src/gtest-port.cc:253:46: error: cannot convert 'RTL_CRITICAL_SECTION*' to 'PCRITICAL_SECTION {aka CRITICAL_SECTION*}' for argument '1' to 'void DeleteCriticalSection(PCRITICAL_SECTION)'
::DeleteCriticalSection(critical_section
);
^
F:/Libs/googletest/src/gtest-port.cc: In member function 'void testing::internal::Mutex::Lock()':
F:/Libs/googletest/src/gtest-port.cc:261:43: error: cannot convert 'RTL_CRITICAL_SECTION*' to 'LPCRITICAL_SECTION {aka CRITICAL_SECTION*}' for argument '1' to 'void EnterCriticalSection(LPCRITICAL_SECTION)'
::EnterCriticalSection(critical_section
);
^
F:/Libs/googletest/src/gtest-port.cc: In member function 'void testing::internal::Mutex::Unlock()':
F:/Libs/googletest/src/gtest-port.cc:271:43: error: cannot convert 'RTL_CRITICAL_SECTION*' to 'LPCRITICAL_SECTION {aka CRITICAL_SECTION*}' for argument '1' to 'void LeaveCriticalSection(LPCRITICAL_SECTION)'
::LeaveCriticalSection(critical_section
);
^
F:/Libs/googletest/src/gtest-port.cc: In member function 'void testing::internal::Mutex::ThreadSafeLazyInit()':
F:/Libs/googletest/src/gtest-port.cc:292:27: error: cannot convert 'CRITICAL_SECTION* {aka CRITICAL_SECTION*}' to 'RTL_CRITICAL_SECTION*' in assignment
critical_section
= new CRITICAL_SECTION;
^
F:/Libs/googletest/src/gtest-port.cc:293:54: error: cannot convert 'RTL_CRITICAL_SECTION*' to 'LPCRITICAL_SECTION {aka CRITICAL_SECTION*}' for argument '1' to 'void InitializeCriticalSection(LPCRITICAL_SECTION)'
::InitializeCriticalSection(critical_section
);
^
F:/Libs/googletest/src/gtest-port.cc: In constructor 'testing::internal::ThreadWithParamBase::ThreadWithParamBase(testing::internal::ThreadWithParamBase::Runnable*, testing::internal::Notification*)':
F:/Libs/googletest/src/gtest-port.cc:377:9: error: class 'testing::internal::ThreadWithParamBase' does not have any field named 'thread
'
: thread
(ThreadWithParamSupport::CreateThread(runnable,
^
In file included from F:/Libs/googletest/include/gtest/internal/gtest-internal.h:40:0,
from F:/Libs/googletest/include/gtest/gtest.h:58,
from F:\Libs\googletest\src\gtest-all.cc:39:
F:/Libs/googletest/src/gtest-port.cc: In member function 'void testing::internal::ThreadWithParamBase::Join()':
F:/Libs/googletest/src/gtest-port.cc:386:38: error: 'thread
' was not declared in this scope
GTEST_CHECK
(::WaitForSingleObject(thread
.Get(), INFINITE) == WAIT_OBJECT_0)
^
F:/Libs/googletest/include/gtest/internal/gtest-port.h:1297:37: note: in definition of macro 'GTEST_CHECK
'
if (::testing::internal::IsTrue(condition))
^
CMakeFiles\gtest.dir\build.make:62: recipe for target 'CMakeFiles/gtest.dir/src/gtest-all.cc.obj' failed
mingw32-make[2]: *** [CMakeFiles/gtest.dir/src/gtest-all.cc.obj] Error 1
CMakeFiles\Makefile2:66: recipe for target 'CMakeFiles/gtest.dir/all' failed
mingw32-make[1]: *** [CMakeFiles/gtest.dir/all] Error 2
Makefile:128: recipe for target 'all' failed
mingw32-make: *** [all] Error 2

@Marc--Olivier
Copy link

Does passing -Dgtest_disable_pthreads=ON to CMake fix the problem? (see #975, #1060)

@demiaowu
Copy link
Author

thank you very much

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

2 participants