-
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
Fix compilation of googletest with MinGW using Win32 threads #721
Conversation
It's not supported, and native Windows threading is available for MinGW
#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; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This breaks compilation with MinGW 5.2.0.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same for me. This breaks compilation on Linux with MinGW 4.8.2
gtest-port.cc:242:45: error: cannot convert ‘CRITICAL_SECTION* {aka _RTL_CRITICAL_SECTION*}’ to ‘GTEST_CRITICAL_SECTION* {aka _CRITICAL_SECTION*}’ in initialization
critical_section_(new CRITICAL_SECTION) {
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fix this in PR #856, but a lot of test still failing with MinGW
Tested with MSVC. All compiles. With recent MinGW it is broken though. |
Simple fix for the compile issues (google#484, google#708) with MinGW 4.8.1. The real fix is under discussion in google#721.
Seems to work with MSVC 2010. But fails for me when trying to build with MinGW (g++ -v: gcc version 4.9.2 (i686-posix-dwarf-rev1, Built by MinGW-W64 project) )
First error is:
|
I believe I was experiencing the same issue late last year (see issue #606 and PR #608). As far as I can understand the original issue is that commit a634042 introduced internal testing of GTests' use of threads, and tried to disable pthreads on MinGW but failed. I tried building GTest master with something similar to PR #608 above, and disabling pthreads on a top-level makes the build work on MinGW. Maybe the best way to go about it would be to first properly disable pthreads, then implement the threading testing when building with MinGW? |
This looks good. Thanks. |
This merge broke compilation on Windows 10 x64 with MinGW 5.3 x32. It comes bundled with Qt 5.7 SDK. Now I get errors like this:
|
fix for opencv#8105, compilation issue with mingw32 (in google/googletest#721 a similar issue was solved and the reason was described as MinGW defines _CRITICAL_SECTION and _RTL_CRITICAL_SECTION as two separate (equivalent) structs, instead of using typedef)
When compiling with MinGW, we no longer need to use -Dgtest_disable_pthreads=ON. See google/googletest#856 and google/googletest#721
When compiling with MinGW, we no longer need to use -Dgtest_disable_pthreads=ON. See google/googletest#856 and google/googletest#721
When compiling with MinGW, we no longer need to use -Dgtest_disable_pthreads=ON. See google/googletest#856 and google/googletest#721
Fixes #708.
Allows to compile googletest with MinGW when pthreads support is disabled.
Also, the cmake build automatically disables pthreads supportwhen MinGW is used.
Tested on Win7, with MinGW 4.8.1, cmake 3.5.0. All tests pass, except for gmock-matchers_test that fails because of a limitation of MinGW not being able to handle "too many sections", most likely unrelated to the issue being addressed here (see below).
Unfortunately, I am not able to (legally) test with MSVC compiler, anybody please help test.
Also tested on Linux, although I expect no differences.
cmake command line used for testing:
cmake -G "MinGW Makefiles" -Dgtest_build_samples=ON -Dgmock_build_samples=ON -Dgtest_build_tests=ON -Dgmock_build_tests=ON ..
MinGW "too many section" issue:
and (after using
make --keep-going
)Apparently this limitation is lifted in recent versions of MinGW64 (when compiling in 64-bit mode), if I get a chance I'll try that too.