Boost logo

Boost Users :

Subject: [Boost-users] Problems using thread and asio libraries together with Boost 1.36.0 on Cygwin
From: Clarke, Carus V (carus.v.clarke_at_[hidden])
Date: 2008-09-24 16:22:47


> I have been using Boost 1.34.1 for quite awhile for a Windows
> application that uses both the Boost thread and asio libraries. The
> application builds successfully using gcc 3.4.4 on Cygwin and both
> MSVC 8.0 and 9.0. Now I am trying to port the application to Boost
> 1.36.0 and have had some problems with the gcc compiler on Cygwin.
> The following (or similar) errors have occured when compiling any file
> that includes a thread library header:
>
> ...
> g++ -o build/ftds/out/OutputManager.o -c -g -mwin32 -mthreads -Wall
> -ansi -D_REENTRANT -D__STRICT_ANSI__ -D_WIN32_WINNT=0x0501
> -D__USE_W32_SOCKETS -DWIN32_LEAN_AND_MEAN -DRWDEBUG=1
> -DRW_MULTI_THREAD -DZAF_BOOL_DEFINED -DZAF_POSIX -DNOMINMAX=1
> -Iinclude -Ic:/cygwin/home/cvc7986/work/boost_1_36_0
> -Ic:/rwave/workspaces/winxp/gcc/15s "-Ic:/Program Files/IVI
> Foundation/VISA/winnt/include" "-Ic:/Program Files/Agilent/IO
> Libraries Suite/include" -Ic:/zaf530/include
> source/ftds/out/OutputManager.cpp
> In file included from /usr/include/cygwin/sys_time.h:13,
> from /usr/include/sys/time.h:27,
> from
> c:/cygwin/home/cvc7986/work/boost_1_36_0/boost/date_time/c_time.hpp:28
> ,
> from
> c:/cygwin/home/cvc7986/work/boost_1_36_0/boost/date_time/microsec_time
> _clock.hpp:18,
> from
> c:/cygwin/home/cvc7986/work/boost_1_36_0/boost/thread/thread_time.hpp:
> 9,
> from
> c:/cygwin/home/cvc7986/work/boost_1_36_0/boost/thread/pthread/timespec
> .hpp:9,
> from
> c:/cygwin/home/cvc7986/work/boost_1_36_0/boost/thread/pthread/conditio
> n_variable.hpp:8,
> from
> c:/cygwin/home/cvc7986/work/boost_1_36_0/boost/thread/condition_variab
> le.hpp:16,
> from
> c:/cygwin/home/cvc7986/work/boost_1_36_0/boost/thread/condition.hpp:9,
> from include/cds/Server.h:29,
> from source/ftds/out/OutputManager.cpp:27:
> /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
> c:/cygwin/home/cvc7986/work/boost_1_36_0/boost/asio/detail/socket_type
> s.hpp:75,
> from
> c:/cygwin/home/cvc7986/work/boost_1_36_0/boost/asio/detail/win_iocp_io
> _service_fwd.hpp:24,
> from
> c:/cygwin/home/cvc7986/work/boost_1_36_0/boost/asio/io_service.hpp:37,
> from
> c:/cygwin/home/cvc7986/work/boost_1_36_0/boost/asio/basic_io_object.hp
> p:20,
> from
> c:/cygwin/home/cvc7986/work/boost_1_36_0/boost/asio/basic_datagram_soc
> ket.hpp:25,
> from
> c:/cygwin/home/cvc7986/work/boost_1_36_0/boost/asio.hpp:20,
> from include/cds/srvr/ConfigurationServer.h:26,
> from include/cds/Server.h:41,
> from source/ftds/out/OutputManager.cpp:27:
> /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
> scons: *** [build/ftds/out/OutputManager.o] Error 1
> ...
>
> I was able to determine that the problem was caused by the inclusion
> of sys/time.h, which includes cygwin/sys_time.h, which then includes
> sys/select.h. The definition of struct fd_set was prevented in
> sys/types.h because macro __USE_W32_SOCKETS had been defined, as is
> required for using the asio library on Cygwin.
>
> My temporary solution to the problem was to disable the definition of
> the BOOST_HAS_GETTIMEOFDAY macro in the Boost header file
> boost/config/platform/cygwin.hpp and to define BOOST_HAS_FTIME macro
> instead:
>
> $ diff ~/work/boost_1_36_0/boost/config/platform/cygwin.hpp
> boost/config/platform/cygwin.hpp
> 27c27,32
> < # define BOOST_HAS_GETTIMEOFDAY
> ---
> > // temp: # define BOOST_HAS_GETTIMEOFDAY
> > # if !defined(__USE_W32_SOCKETS) // temp
> > # define BOOST_HAS_GETTIMEOFDAY // temp
> > # else // temp
> > # define BOOST_HAS_FTIME // temp
> > # endif // temp
>
> This has solved the problem for me as of now, but it would be good to
> know if there is a better way to solve this. I was not able to find
> any references to this problem in any of the Boost lists.
>
Thanks in advance,

> Carus V. (Bud) Clarke
> carus.v.clarke_at_[hidden]
>


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net