error: 'condition_variable_any' in namespace 'std' does not name a type with WIN32 Threading
Author: CommanderBubbleCreated Apr 8, 2020Updated Jul 22, 2026
Issue description
Building on Windows with MinGW_w64 fails when using Win32 threading model, using CMake and Ninja
Environment
- libzmq version 4.3.2
- OS: Windows 10 64bit 1903
- MinGW: x64 8.1.0 release win32 threads SEH
Minimal test code / Steps to reproduce the issue
make MinGW w64 gcc with WIN32 threading model detected compiler build using CMake and Ninja.
What's the actual result? (include assertion message & call stack if applicable)
[0/1] Re-running CMake...
-- Detected ZMQ Version - 4.3.2
-- Using tweetnacl for CURVE security
-- Using polling method in I/O threads: select
-- Using polling method in zmq_poll(er)_* API: select
-- Using 64 bytes alignment for lock-free data structures
-- Detected _WIN32_WINNT from CMAKE_SYSTEM_VERSION: 0x0A00
-- Using condition_variable_t implementation: stl11
-- Checking whether noexcept is supported
-- Checking whether SOCK_CLOEXEC is supported
-- Checking whether O_CLOEXEC is supported
-- Checking whether SO_BINDTODEVICE is supported
-- Checking whether SO_KEEPALIVE is supported
-- Checking whether TCP_KEEPCNT is supported
-- Checking whether TCP_KEEPIDLE is supported
-- Checking whether TCP_KEEPINTVL is supported
-- Checking whether TCP_KEEPALIVE is supported
-- Checking whether TIPC is supported
-- Checking pthread_setname signature
-- Checking pthread_setaffinity signature
-- Checking whether getrandom is supported
-- Could NOT find AsciiDoc (missing: ASCIIDOC_EXECUTABLE)
-- capsh not found, skipping tests that require CAP_NET_ADMIN
CMake Warning (dev) at tests/CMakeLists.txt:294 (message):
Test 'test_socks' is not known to CTest.
This warning is for project developers. Use -Wno-dev to suppress it.
-- Configuring done
-- Generating done
-- Build files have been written to: C:/Code/ZMQ/Latest/cmake
[25/378] Building CXX object CMakeFiles/libzmq.dir/src/mailbox_safe.cpp.obj
FAILED: CMakeFiles/libzmq.dir/src/mailbox_safe.cpp.obj
C:\Code\mingw-w64\mingw64\bin\c++.exe -DDLL_EXPORT -DFD_SETSIZE=16384 -DZMQ_CUSTOM_PLATFORM_HPP -D_CRT_SECURE_NO_WARNINGS -D_REENTRANT -D_THREAD_SAFE -D_WIN32_WINNT=0x0A00 -D_WINSOCK_DEPRECATED_NO_WARNINGS -Dlibzmq_EXPORTS -I../include -I. -std=gnu++11 -Wno-tautological-constant-compare -O3 -DNDEBUG -MD -MT CMakeFiles/libzmq.dir/src/mailbox_safe.cpp.obj -MF CMakeFiles\libzmq.dir\src\mailbox_safe.cpp.obj.d -o CMakeFiles/libzmq.dir/src/mailbox_safe.cpp.obj -c ../src/mailbox_safe.cpp
In file included from ../src/mailbox_safe.hpp:43,
from ../src/mailbox_safe.cpp:31:
../src/condition_variable.hpp:140:10: error: 'condition_variable_any' in namespace 'std' does not name a type
std::condition_variable_any _cv;
^~~~~~~~~~~~~~~~~~~~~~
../src/condition_variable.hpp:140:5: note: 'std::condition_variable_any' is defined in header '<condition_variable>'; did you forget to '#include <condition_variable>'?
../src/condition_variable.hpp:107:1:
+#include <condition_variable>
../src/condition_variable.hpp:140:5:
std::condition_variable_any _cv;
^~~
../src/condition_variable.hpp: In member function 'int zmq::condition_variable_t::wait(zmq::mutex_t*, int)':
../src/condition_variable.hpp:122:13: error: '_cv' was not declared in this scope
_cv.wait (
^~~
../src/condition_variable.hpp:122:13: note: suggested alternative: 'recv'
_cv.wait (
^~~
recv
../src/condition_variable.hpp:124:20: error: '_cv' was not declared in this scope
} else if (_cv.wait_for (*mutex_, std::chrono::milliseconds (timeout_))
^~~
../src/condition_variable.hpp:124:20: note: suggested alternative: 'recv'
} else if (_cv.wait_for (*mutex_, std::chrono::milliseconds (timeout_))
^~~
recv
../src/condition_variable.hpp:125:28: error: 'std::cv_status' has not been declared
== std::cv_status::timeout) {
^~~~~~~~~
../src/condition_variable.hpp: In member function 'void zmq::condition_variable_t::broadcast()':
../src/condition_variable.hpp:136:9: error: '_cv' was not declared in this scope
_cv.notify_all ();
^~~
../src/condition_variable.hpp:136:9: note: suggested alternative: 'recv'
_cv.notify_all ();
^~~
recv
At global scope:
cc1plus.exe: warning: unrecognized command line option '-Wno-tautological-constant-compare'
[34/378] Building CXX object CMakeFiles/libzmq.dir/src/norm_engine.cpp.obj
ninja: build stopped: subcommand failed.What's the expected result?
The build should be able to succeed or
- the build should not be able to proceed, and the reason reported should be that the threading model is not able to be used
- detect the threading model and use WIN32API threading instead of STL11 for this (unsure if it would work or how it would be done)
Source: zeromq/libzmq