libzmq icon indicating copy to clipboard operation
libzmq copied to clipboard

error: 'condition_variable_any' in namespace 'std' does not name a type with WIN32 Threading

Open CommanderBubble opened this issue 4 years ago • 9 comments

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)

CommanderBubble avatar Apr 08 '20 05:04 CommanderBubble

just tested same build for 4.3.1, the issue does not exist there

CommanderBubble avatar Apr 08 '20 05:04 CommanderBubble

Looking at condition_variable.hpp, the checking around windows changed between releases. The check for which version is now done by cmake, setting (in my particular case) the variable ZMQ_USE_CV_IMPL_STL11 to 1, and for some reason this is not able to build.

CommanderBubble avatar Apr 08 '20 06:04 CommanderBubble

I've encountered the same issue in libzmq version 4.3.3:

  • libzmq version 4.3.3
  • OS: Debian stable
  • x86_64-w64-mingw32-gcc

gojmpz avatar Oct 31 '20 07:10 gojmpz

This issue has been automatically marked as stale because it has not had activity for 365 days. It will be closed if no further activity occurs within 56 days. Thank you for your contributions.

stale[bot] avatar Apr 16 '22 18:04 stale[bot]

same issue with 4.3.4

agowa avatar Jun 27 '22 21:06 agowa

I ended up on this issue due to having a similar issue on AIX. For other people in the same boat, make sure you have -pthread in your CFLAGS, CXXFLAGS, and LDFLAGS. -lpthread isn't sufficient on AIX, and C++ types depending on threading won't be present.

Taywee avatar Aug 24 '22 21:08 Taywee

I am having the same issue

  • zmq version 4.3.3
  • OS: Ubuntu 20.04
  • x86_64-w64-mingw32-gcc

sneurlax avatar Nov 15 '22 17:11 sneurlax

I was able to move past this issue by reverting to 4.3.1 as @CommanderBubble said! Version 4.3.4 also has this issue.

sneurlax avatar Nov 15 '22 17:11 sneurlax

Any updates here? I'm running into the same issue while building the Windows Ruby gems for czmq-ffi-gen.

I'm using v4.3.5

...
[ 25%] Building CXX object CMakeFiles/libzmq.dir/src/msg.cpp.obj
[ 25%] Building CXX object CMakeFiles/libzmq-static.dir/src/epoll.cpp.obj
In file included from /czmq-ffi-gen/vendor/libzmq/src/mailbox_safe.hpp:16,
                 from /czmq-ffi-gen/vendor/libzmq/src/mailbox_safe.cpp:4:
/czmq-ffi-gen/vendor/libzmq/src/condition_variable.hpp:102:10: error: 'condition_variable_any' in namespace 'std' does not name a type
  102 |     std::condition_variable_any _cv;
      |          ^~~~~~~~~~~~~~~~~~~~~~
/czmq-ffi-gen/vendor/libzmq/src/condition_variable.hpp:71:1: note: 'std::condition_variable_any' is defined in header '<condition_variable>'; did you forget to '#include <condition_variable>'?
   70 | #include <condition_variable>
  +++ |+#include <condition_variable>
   71 |

The suggestion about including <condition_variable> is already in src/condition_variable.hpp.

Docker image: Ubuntu 22.04 (building for mingw)

paddor avatar Jan 07 '24 23:01 paddor