-
Notifications
You must be signed in to change notification settings - Fork 10.2k
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
Can't compile with MinGW (Win8 x64) #606
Comments
Hi, I'm having the same problem, using the MinGW system supplied with Qt 5.5. |
Submitted a PR with a patch fixing it on my system. Seems like perhaps the existing way of disabling pthreads when compiling with MinGW was somewhat lacking. |
@andoks I'm using the same compiler. Was it working with other mingw versions? |
AFAIK it has never worked for our team when using CMake, we are in the process of converting to using CMake (with hunter) $ g++ --version
g++.exe (i686-posix-dwarf-rev1, Built by MinGW-W64 project) 4.9.2
Copyright (C) 2014 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
$ mingw32-make.exe --version
GNU Make 4.1
Built for i686-w64-mingw32
Copyright (C) 1988-2014 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
$ qmake --version
QMake version 3.0
Using Qt version 5.5.0 in C:/tools/Qt/Qt5/5.5/mingw492_32/lib
$ cmake --version
cmake version 3.2.3
CMake suite maintained and supported by Kitware (kitware.com/cmake). |
Configuring with -DSHADERC_SKIP_TESTS=ON will prevent building any tests based on gtest or gmock. Required for cross compiling from Linux to Windows with MinGW since it seems MinGW can't compile googletest. See google/googletest#606 Change-Id: I31cb0568f335debb1767b93a5f9067df6848973b
Configuring with -DSHADERC_SKIP_TESTS=ON will prevent building any tests based on gtest or gmock. Required for cross compiling from Linux to Windows with MinGW since it seems MinGW can't compile googletest. See google/googletest#606 To compile on Linux targeting Windows, do this: cmake -DCMAKE_SYSTEM_NAME=Windows \ -DCMAKE_C_COMPILER=i686-w64-mingw32-gcc \ -DCMAKE_CXX_COMPILER=i686-w64-mingw32-g++ \ -DSHADERC_SKIP_TESTS=ON \ $SHADERC_SRC_DIR Change-Id: I31cb0568f335debb1767b93a5f9067df6848973b
Add a toolchain file for Linux MinGW build for Windows. Add CMake variable SHADERC_SKIP_TESTS. Configuring with -DSHADERC_SKIP_TESTS=ON will prevent building any tests based on gtest or gmock. - Required for cross compiling from Linux to Windows with MinGW since it seems MinGW can't compile googletest. See google/googletest#606 To compile on Linux targeting Windows, do this: cmake -DCMAKE_TOOLCHAIN_FILE=$SHADERC_SRC_DIR/cmake/linux-mingw-tooclhain.cmake \ -DSHADERC_SKIP_TESTS=ON \ $SHADERC_SRC_DIR Change-Id: I167b88e1808f51005fe47d1b28593b0b4249d81b
Configuring with -DSHADERC_SKIP_TESTS=ON will prevent building any tests based on gtest or gmock. Required for cross compiling from Linux to Windows with MinGW since it seems MinGW can't compile googletest. See google/googletest#606 To compile on Linux targeting Windows, do this: cmake -DCMAKE_SYSTEM_NAME=Windows \ -DCMAKE_C_COMPILER=i686-w64-mingw32-gcc \ -DCMAKE_CXX_COMPILER=i686-w64-mingw32-g++ \ -DSHADERC_SKIP_TESTS=ON \ $SHADERC_SRC_DIR Change-Id: I31cb0568f335debb1767b93a5f9067df6848973b
Same problem compiling googletest with mingw for me with: $ /usr/bin/i686-w64-mingw32-g++ --version $ cmake --version |
David, your CMake must be newer than 3.0: Notes about version of CMake 3.0.0 Minimum required |
A bad interaction between CMake, MinGW, and Googletest prevents MinGW from compiling Googletest with threads. google/googletest#606 So we must configure Googletest without threading support.
@WesleyCeraso You're right, my workspace is out of date. :-( Turns out that I can work around the issue by configuring the project with -Dgoogle_disable_pthreads=ON But point taken, we should look at updating versions of our tools. |
A bad interaction between CMake, MinGW, and Googletest prevents MinGW from compiling Googletest with threads. google/googletest#606 So we must configure Googletest without threading support.
A bad interaction between CMake, MinGW, and Googletest prevents MinGW from compiling Googletest with threads. google/googletest#606 So we must configure Googletest without threading support.
I found a solution for this. Line 607: #if GTEST_HAS_PTHREAD && !GTEST_OS_WINDOWS_MINGW I think it is a mistake because gtest creators do not use mingw. With this changes you'll maintain threading support in windows. |
@dvdjg Do you mind making a pull request to fix this bug? Thanks! |
I cannot believe it has persisted for almost one year. |
Google Test have several pull requests about that PR #721 should fix this |
Merged #721 I don't have a mingw to try it on, but it looks reasonable. Thanks for your patience. |
For mingw32 - 5.3 compiler pointer casting errors appeared in gtest-port.cc, had to use reinterpret_cast in every usage of critical_section_ member in Mutex class |
I'm also having trouble building using CMake and MinGW32, building on a Linux host. Cross-compiling for Windows 32-bit. My versions are: $ /home/mellertson/Downloads/clion-2016.2.2/bin/cmake/bin/cmake --version $ /usr/bin/i686-w64-mingw32-g++ --version $ uname -a And here's my build output: |
Hi @mellertson: How did you initially configure with cmake? |
This is a known bug in Google Test: google/googletest#606 modified: README.md
#1051 |
Hi, I'm having trouble building GTest with MinGW, I used bisect to find the commit that broke the build:
a634042 is the first bad commit
commit a634042
Author: kosak kosak@google.com
Date: Mon Mar 24 21:58:25 2014 +0000
The build step output:
$ cmake --build .
[ 25%] Building CXX object CMakeFiles/gtest.dir/src/gtest-all.cc.obj
In file included from C:/Users/wprudencio/gtest-1.7.0-hunter-11/include/gtest/internal/gtest-internal.h:40:0,
from C:/Users/wprudencio/gtest-1.7.0-hunter-11/include/gtest/gtest.h:58,
from C:\Users\wprudencio\gtest-1.7.0-hunter-11\src\gtest-all.cc:39:
C:/Users/wprudencio/gtest-1.7.0-hunter-11/include/gtest/internal/gtest-port.h:1704:3: error: 'AutoHandle' does not name a type
AutoHandle thread_;
^
In file included from C:\Users\wprudencio\gtest-1.7.0-hunter-11\src\gtest-all.cc:43:0:
C:/Users/wprudencio/gtest-1.7.0-hunter-11/src/gtest-death-test.cc:626:3: error: 'AutoHandle' does not name a type
AutoHandle write_handle_;
^
C:/Users/wprudencio/gtest-1.7.0-hunter-11/src/gtest-death-test.cc:628:3: error: 'AutoHandle' does not name a type
AutoHandle child_handle_;
^
C:/Users/wprudencio/gtest-1.7.0-hunter-11/src/gtest-death-test.cc:633:3: error: 'AutoHandle' does not name a type
AutoHandle event_handle_;
^
C:/Users/wprudencio/gtest-1.7.0-hunter-11/src/gtest-death-test.cc: In member function 'virtual int testing::internal::WindowsDeathTest::Wait()':
C:/Users/wprudencio/gtest-1.7.0-hunter-11/src/gtest-death-test.cc:645:36: error: 'child_handle_' was not declared in this scope
const HANDLE wait_handles[2] = { child_handle_.Get(), event_handle_.Get() };
^
C:/Users/wprudencio/gtest-1.7.0-hunter-11/src/gtest-death-test.cc:645:57: error: 'event_handle_' was not declared in this scope
const HANDLE wait_handles[2] = { child_handle_.Get(), event_handle_.Get() };
^
C:/Users/wprudencio/gtest-1.7.0-hunter-11/src/gtest-death-test.cc:659:3: error: 'write_handle_' was not declared in this scope
write_handle_.Reset();
^
C:/Users/wprudencio/gtest-1.7.0-hunter-11/src/gtest-death-test.cc: In member function 'virtual testing::internal::DeathTest::TestRole testing::internal::WindowsDeathTest::AssumeRole()':
C:/Users/wprudencio/gtest-1.7.0-hunter-11/src/gtest-death-test.cc:709:3: error: 'write_handle_' was not declared in this scope
write_handle_.Reset(write_handle);
^
C:/Users/wprudencio/gtest-1.7.0-hunter-11/src/gtest-death-test.cc:710:3: error: 'event_handle_' was not declared in this scope
event_handle_.Reset(::CreateEvent(
^
C:/Users/wprudencio/gtest-1.7.0-hunter-11/src/gtest-death-test.cc:766:3: error: 'child_handle_' was not declared in this scope
child_handle_.Reset(process_info.hProcess);
^
C:/Users/wprudencio/gtest-1.7.0-hunter-11/src/gtest-death-test.cc: In function 'int testing::internal::GetStatusFileDescriptor(unsigned int, size_t, size_t)':
C:/Users/wprudencio/gtest-1.7.0-hunter-11/src/gtest-death-test.cc:1232:3: error: 'AutoHandle' was not declared in this scope
AutoHandle parent_process_handle(::OpenProcess(PROCESS_DUP_HANDLE,
^
C:/Users/wprudencio/gtest-1.7.0-hunter-11/src/gtest-death-test.cc:1235:7: error: 'parent_process_handle' was not declared in this scope
if (parent_process_handle.Get() == INVALID_HANDLE_VALUE) {
^
C:/Users/wprudencio/gtest-1.7.0-hunter-11/src/gtest-death-test.cc:1251:26: error: 'parent_process_handle' was not declared in this scope
if (!::DuplicateHandle(parent_process_handle.Get(), write_handle,
^
C:/Users/wprudencio/gtest-1.7.0-hunter-11/src/gtest-death-test.cc:1266:26: error: 'parent_process_handle' was not declared in this scope
if (!::DuplicateHandle(parent_process_handle.Get(), event_handle,
^
In file included from C:\Users\wprudencio\gtest-1.7.0-hunter-11\src\gtest-all.cc:45:0:
C:/Users/wprudencio/gtest-1.7.0-hunter-11/src/gtest-port.cc: In function 'void testing::internal::SleepMilliseconds(int)':
C:/Users/wprudencio/gtest-1.7.0-hunter-11/src/gtest-port.cc:139:6: error: redefinition of 'void testing::internal::SleepMilliseconds(int)'
void SleepMilliseconds(int n) {
^
In file included from C:/Users/wprudencio/gtest-1.7.0-hunter-11/include/gtest/internal/gtest-internal.h:40:0,
from C:/Users/wprudencio/gtest-1.7.0-hunter-11/include/gtest/gtest.h:58,
from C:\Users\wprudencio\gtest-1.7.0-hunter-11\src\gtest-all.cc:39:
C:/Users/wprudencio/gtest-1.7.0-hunter-11/include/gtest/internal/gtest-port.h:1377:13: note: 'void testing::internal::SleepMilliseconds(int)' previously defined here
inline void SleepMilliseconds(int n) {
^
In file included from C:\Users\wprudencio\gtest-1.7.0-hunter-11\src\gtest-all.cc:45:0:
C:/Users/wprudencio/gtest-1.7.0-hunter-11/src/gtest-port.cc: At global scope:
C:/Users/wprudencio/gtest-1.7.0-hunter-11/src/gtest-port.cc:143:1: error: 'AutoHandle' does not name a type
AutoHandle::AutoHandle()
^
C:/Users/wprudencio/gtest-1.7.0-hunter-11/src/gtest-port.cc:146:1: error: 'AutoHandle' does not name a type
AutoHandle::AutoHandle(Handle handle)
^
C:/Users/wprudencio/gtest-1.7.0-hunter-11/src/gtest-port.cc:149:1: error: 'AutoHandle' does not name a type
AutoHandle::~AutoHandle() {
^
C:/Users/wprudencio/gtest-1.7.0-hunter-11/src/gtest-port.cc:153:1: error: 'AutoHandle' does not name a type
AutoHandle::Handle AutoHandle::Get() const {
^
C:/Users/wprudencio/gtest-1.7.0-hunter-11/src/gtest-port.cc:157:6: error: 'AutoHandle' has not been declared
void AutoHandle::Reset() {
^
C:/Users/wprudencio/gtest-1.7.0-hunter-11/src/gtest-port.cc: In function 'void testing::internal::Reset()':
C:/Users/wprudencio/gtest-1.7.0-hunter-11/src/gtest-port.cc:158:29: error: too many arguments to function 'void testing::internal::Reset()'
Reset(INVALID_HANDLE_VALUE);
^
C:/Users/wprudencio/gtest-1.7.0-hunter-11/src/gtest-port.cc:157:6: note: declared here
void AutoHandle::Reset() {
^
C:/Users/wprudencio/gtest-1.7.0-hunter-11/src/gtest-port.cc: At global scope:
C:/Users/wprudencio/gtest-1.7.0-hunter-11/src/gtest-port.cc:161:6: error: 'AutoHandle' has not been declared
void AutoHandle::Reset(HANDLE handle) {
^
C:/Users/wprudencio/gtest-1.7.0-hunter-11/src/gtest-port.cc: In function 'void testing::internal::Reset(HANDLE)':
C:/Users/wprudencio/gtest-1.7.0-hunter-11/src/gtest-port.cc:163:7: error: 'handle_' was not declared in this scope
if (handle_ != handle) {
^
C:/Users/wprudencio/gtest-1.7.0-hunter-11/src/gtest-port.cc:164:21: error: 'IsCloseable' was not declared in this scope
if (IsCloseable()) {
^
In file included from C:/Users/wprudencio/gtest-1.7.0-hunter-11/include/gtest/internal/gtest-internal.h:40:0,
from C:/Users/wprudencio/gtest-1.7.0-hunter-11/include/gtest/gtest.h:58,
from C:\Users\wprudencio\gtest-1.7.0-hunter-11\src\gtest-all.cc:39:
C:/Users/wprudencio/gtest-1.7.0-hunter-11/src/gtest-port.cc:169:31: error: 'IsCloseable' was not declared in this scope
GTEST_CHECK_(!IsCloseable())
^
C:/Users/wprudencio/gtest-1.7.0-hunter-11/include/gtest/internal/gtest-port.h:1250:37: note: in definition of macro 'GTEST_CHECK_'
if (::testing::internal::IsTrue(condition))
^
In file included from C:\Users\wprudencio\gtest-1.7.0-hunter-11\src\gtest-all.cc:45:0:
C:/Users/wprudencio/gtest-1.7.0-hunter-11/src/gtest-port.cc: At global scope:
C:/Users/wprudencio/gtest-1.7.0-hunter-11/src/gtest-port.cc:175:6: error: 'AutoHandle' has not been declared
bool AutoHandle::IsCloseable() const {
^
C:/Users/wprudencio/gtest-1.7.0-hunter-11/src/gtest-port.cc:175:32: error: non-member function 'bool testing::internal::IsCloseable()' cannot have cv-qualifier
bool AutoHandle::IsCloseable() const {
^
C:/Users/wprudencio/gtest-1.7.0-hunter-11/src/gtest-port.cc: In function 'bool testing::internal::IsCloseable()':
C:/Users/wprudencio/gtest-1.7.0-hunter-11/src/gtest-port.cc:178:10: error: 'handle_' was not declared in this scope
return handle_ != NULL && handle_ != INVALID_HANDLE_VALUE;
^
C:/Users/wprudencio/gtest-1.7.0-hunter-11/src/gtest-port.cc: At global scope:
C:/Users/wprudencio/gtest-1.7.0-hunter-11/src/gtest-port.cc:181:1: error: redefinition of 'testing::internal::Notification::Notification()'
Notification::Notification()
^
In file included from C:/Users/wprudencio/gtest-1.7.0-hunter-11/include/gtest/internal/gtest-internal.h:40:0,
from C:/Users/wprudencio/gtest-1.7.0-hunter-11/include/gtest/gtest.h:58,
from C:\Users\wprudencio\gtest-1.7.0-hunter-11\src\gtest-all.cc:39:
C:/Users/wprudencio/gtest-1.7.0-hunter-11/include/gtest/internal/gtest-port.h:1396:3: note: 'testing::internal::Notification::Notification()' previously defined here
Notification() : notified_(false) {
^
In file included from C:\Users\wprudencio\gtest-1.7.0-hunter-11\src\gtest-all.cc:45:0:
C:/Users/wprudencio/gtest-1.7.0-hunter-11/src/gtest-port.cc:189:6: error: redefinition of 'void testing::internal::Notification::Notify()'
void Notification::Notify() {
^
In file included from C:/Users/wprudencio/gtest-1.7.0-hunter-11/include/gtest/internal/gtest-internal.h:40:0,
from C:/Users/wprudencio/gtest-1.7.0-hunter-11/include/gtest/gtest.h:58,
from C:\Users\wprudencio\gtest-1.7.0-hunter-11\src\gtest-all.cc:39:
C:/Users/wprudencio/gtest-1.7.0-hunter-11/include/gtest/internal/gtest-port.h:1405:8: note: 'void testing::internal::Notification::Notify()' previously defined here
void Notify() {
^
In file included from C:\Users\wprudencio\gtest-1.7.0-hunter-11\src\gtest-all.cc:45:0:
C:/Users/wprudencio/gtest-1.7.0-hunter-11/src/gtest-port.cc:193:6: error: redefinition of 'void testing::internal::Notification::WaitForNotification()'
void Notification::WaitForNotification() {
^
In file included from C:/Users/wprudencio/gtest-1.7.0-hunter-11/include/gtest/internal/gtest-internal.h:40:0,
from C:/Users/wprudencio/gtest-1.7.0-hunter-11/include/gtest/gtest.h:58,
from C:\Users\wprudencio\gtest-1.7.0-hunter-11\src\gtest-all.cc:39:
C:/Users/wprudencio/gtest-1.7.0-hunter-11/include/gtest/internal/gtest-port.h:1413:8: note: 'void testing::internal::Notification::WaitForNotification()' previously defined here
void WaitForNotification() {
^
C:/Users/wprudencio/gtest-1.7.0-hunter-11/include/gtest/internal/gtest-port.h: In constructor 'testing::internal::Mutex::Mutex()':
C:/Users/wprudencio/gtest-1.7.0-hunter-11/include/gtest/internal/gtest-port.h:1616:13: warning: 'testing::internal::Mutex::type_' will be initialized after [-Wreorder]
MutexType type_;
^
C:/Users/wprudencio/gtest-1.7.0-hunter-11/include/gtest/internal/gtest-port.h:1612:16: warning: 'unsigned int testing::internal::Mutex::owner_thread_id_' [-Wreorder]
unsigned int owner_thread_id_;
^
In file included from C:\Users\wprudencio\gtest-1.7.0-hunter-11\src\gtest-all.cc:45:0:
C:/Users/wprudencio/gtest-1.7.0-hunter-11/src/gtest-port.cc:198:1: warning: when initialized here [-Wreorder]
Mutex::Mutex()
^
C:/Users/wprudencio/gtest-1.7.0-hunter-11/src/gtest-port.cc: In constructor 'testing::internal::ThreadWithParamBase::ThreadWithParamBase(testing::internal::ThreadWithParamBase::Runnable, testing::internal::Notification)':
C:/Users/wprudencio/gtest-1.7.0-hunter-11/src/gtest-port.cc:337:9: error: class 'testing::internal::ThreadWithParamBase' does not have any field named 'thread_'
: thread_(ThreadWithParamSupport::CreateThread(runnable,
^
In file included from C:/Users/wprudencio/gtest-1.7.0-hunter-11/include/gtest/internal/gtest-internal.h:40:0,
from C:/Users/wprudencio/gtest-1.7.0-hunter-11/include/gtest/gtest.h:58,
from C:\Users\wprudencio\gtest-1.7.0-hunter-11\src\gtest-all.cc:39:
C:/Users/wprudencio/gtest-1.7.0-hunter-11/src/gtest-port.cc: In member function 'void testing::internal::ThreadWithParamBase::Join()':
C:/Users/wprudencio/gtest-1.7.0-hunter-11/src/gtest-port.cc:346:38: error: 'thread_' was not declared in this scope
GTEST_CHECK_(::WaitForSingleObject(thread_.Get(), INFINITE) == WAIT_OBJECT_0)
^
C:/Users/wprudencio/gtest-1.7.0-hunter-11/include/gtest/internal/gtest-port.h:1250:37: note: in definition of macro 'GTEST_CHECK_'
if (::testing::internal::IsTrue(condition))
^
In file included from C:\Users\wprudencio\gtest-1.7.0-hunter-11\src\gtest-all.cc:45:0:
C:/Users/wprudencio/gtest-1.7.0-hunter-11/src/gtest-port.cc: In function 'bool testing::internal::IsCloseable()':
C:/Users/wprudencio/gtest-1.7.0-hunter-11/src/gtest-port.cc:179:1: warning: control reaches end of non-void function [-Wreturn-type]
}
^
In file included from C:\Users\wprudencio\gtest-1.7.0-hunter-11\src\gtest-all.cc:43:0:
C:/Users/wprudencio/gtest-1.7.0-hunter-11/src/gtest-death-test.cc: At global scope:
C:/Users/wprudencio/gtest-1.7.0-hunter-11/src/gtest-death-test.cc:123:13: warning: 'testing::internal::g_in_fast_death_test_child' defined but not used [-Wunused-variable]
static bool g_in_fast_death_test_child = false;
^
CMakeFiles\gtest.dir\build.make:62: recipe for target 'CMakeFiles/gtest.dir/src/gtest-all.cc.obj' failed
mingw32-make.exe[2]: *** [CMakeFiles/gtest.dir/src/gtest-all.cc.obj] Error 1
CMakeFiles\Makefile2:66: recipe for target 'CMakeFiles/gtest.dir/all' failed
mingw32-make.exe[1]: *** [CMakeFiles/gtest.dir/all] Error 2
makefile:126: recipe for target 'all' failed
mingw32-make.exe: *** [all] Error 2
The text was updated successfully, but these errors were encountered: