[asio and thread] don't play well together under cygwin?

Greetings, I have a header file that includes both <boost/thread> and <boost/asio>, which results in the compilation errors below under cygwin. If I take out <boost/thread> then things are fine, except that I need it for my application :) I have "-D__USE_W32_SOCKETS -D_WIN32_WINNT=0x0501" in my compile flags, per the asio documentation. Taking them out appears to resolve the errors below, but causes other errors for asio. Has anyone else run into this problem and found a solution? -Brian In file included from /usr/include/cygwin/sys_time.h:13, from /usr/include/sys/time.h:27, from /usr/local/include/boost-1_38/boost/date_time/c_time.hpp:31, from /usr/local/include/boost-1_38/boost/date_time/microsec_time_clock.hpp:21, from /usr/local/include/boost-1_38/boost/thread/thread_time.hpp:9, from /usr/local/include/boost-1_38/boost/thread/locks.hpp:12, from /usr/local/include/boost-1_38/boost/thread/pthread/mutex.hpp:11, from /usr/local/include/boost-1_38/boost/thread/mutex.hpp:16, from /usr/local/include/boost-1_38/boost/thread/pthread/thread_data.hpp:12, from /usr/local/include/boost-1_38/boost/thread/thread.hpp:17, from /usr/local/include/boost-1_38/boost/thread.hpp:13, from chat.cpp:23: /usr/include/sys/select.h:31: error: `fd_set' has not been declared /usr/include/sys/select.h:31: error: `fd_set' has not been declared /usr/include/sys/select.h:31: error: `fd_set' has not been declared /usr/include/sys/select.h:33: error: `fd_set' has not been declared /usr/include/sys/select.h:33: error: `fd_set' has not been declared /usr/include/sys/select.h:33: error: `fd_set' has not been declared In file included from /usr/local/include/boost-1_38/boost/asio/detail/socket_types.hpp:79, from /usr/local/include/boost-1_38/boost/asio/detail/win_iocp_io_service_fwd.hpp:24, from /usr/local/include/boost-1_38/boost/asio/io_service.hpp:37, from /usr/local/include/boost-1_38/boost/asio/basic_io_object.hpp:20, from /usr/local/include/boost-1_38/boost/asio/basic_socket.hpp:24, from /usr/local/include/boost-1_38/boost/asio/basic_datagram_socket.hpp:25, from /usr/local/include/boost-1_38/boost/asio.hpp:20, from chat.cpp:30: /usr/lib/gcc/i686-pc-cygwin/3.4.4/../../../../include/w32api/winsock2.h:109: error: redefinition of `struct timeval' /usr/include/sys/time.h:16: error: previous definition of `struct timeval' /usr/lib/gcc/i686-pc-cygwin/3.4.4/../../../../include/w32api/winsock2.h:632: error: declaration of C function `int select(int, fd_set*, fd_set*, fd_set*, const timeval*)' conflicts with /usr/include/sys/select.h:31: error: previous declaration `int select(int, int*, int*, int*, timeval*)' here

AMDG Brian and Victoria wrote:
I have a header file that includes both <boost/thread> and <boost/asio>, which results in the compilation errors below under cygwin. If I take out <boost/thread> then things are fine, except that I need it for my application :) I have "-D__USE_W32_SOCKETS -D_WIN32_WINNT=0x0501" in my compile flags, per the asio documentation. Taking them out appears to resolve the errors below, but causes other errors for asio.
Has anyone else run into this problem and found a solution?
See https://svn.boost.org/trac/boost/ticket/2660 In Christ, Steven Watanabe

I'm having trouble parsing the documentation, and am trying to determine if asio supports gethostbyaddr() functionality. The resolver appears to support hostname to addr queries, but I'm looking for addr to hostname (e.g., 127.0.0.1 maps to localhost). If so, a pointer to an example would be greatly appreciated. Thanks, Brian

This took several hours of web searching and trying to make sense of the asio documentation, but... <snip> boost::asio::ip::tcp::endpoint ep(boost::asio::ip::address_v4(0xD155AB64), 80); // 209.85.171.100:80 boost::asio::ip::tcp::resolver resolver(ios); boost::asio::ip::tcp::resolver::iterator iter = resolver.resolve(ep); boost::asio::ip::tcp::resolver::iterator end; while (iter != end) { std::cerr << (*iter).host_name() << std::endl; // cg-in-f100.google.com ++iter; } <snip> ...produces the desired results. I'm posting this because I found other posts like mine that had not been responded to. -Brian Brian and Victoria wrote:
I'm having trouble parsing the documentation, and am trying to determine if asio supports gethostbyaddr() functionality.
The resolver appears to support hostname to addr queries, but I'm looking for addr to hostname (e.g., 127.0.0.1 maps to localhost).
If so, a pointer to an example would be greatly appreciated.
Thanks, Brian

On Mar 14, 2009, at 3:20 PM, Brian and Victoria wrote:
This took several hours of web searching and trying to make sense of the asio documentation, but...
<snip> boost::asio::ip::tcp::endpoint ep(boost::asio::ip::address_v4(0xD155AB64), 80); // 209.85.171.100:80 boost::asio::ip::tcp::resolver resolver(ios); boost::asio::ip::tcp::resolver::iterator iter = resolver.resolve(ep); boost::asio::ip::tcp::resolver::iterator end; while (iter != end) { std::cerr << (*iter).host_name() << std::endl; // cg-in- f100.google.com ++iter; } <snip>
...produces the desired results.
I'm posting this because I found other posts like mine that had not been responded to.
Thanks for posting this....may be this could *now* be included in the documentation..... Ciao, Andreas
participants (3)
-
Andreas Masur
-
Brian and Victoria
-
Steven Watanabe