如何使用Cygwin 64位的boost asio库

时间:2016-10-06 10:49:28

标签: c++ boost cygwin windows-10 boost-asio

我正在运行Windows 10 64位。 Cygwin是64位。

我从cygwin包管理器安装了boost。

我尝试编译test.cpp:

#include <boost/asio.hpp>
int
main(int argc, char**argv)
{
    return 0;
}

使用命令

g++ -std=c++11 -Wall -g  -D__USE_W32_SOCKETS D_WIN32_WINNT=_WIN32_WINNT_WIN7 test.cpp -o test.exe

但编译失败。 看起来正在使用posix

为什么会失败的任何想法?

In file included from /usr/include/boost/asio/detail/fd_set_adapter.hpp:22:0,
             from /usr/include/boost/asio/detail/select_reactor.hpp:27,
             from /usr/include/boost/asio/detail/reactor.hpp:29,
             from /usr/include/boost/asio/detail/impl/task_io_service.ipp:24,
             from /usr/include/boost/asio/detail/task_io_service.hpp:198,
             from /usr/include/boost/asio/impl/io_service.hpp:71,
             from /usr/include/boost/asio/io_service.hpp:767,
             from /usr/include/boost/asio/basic_io_object.hpp:19,
             from /usr/include/boost/asio/basic_socket.hpp:20,
             from /usr/include/boost/asio/basic_datagram_socket.hpp:20,
             from /usr/include/boost/asio.hpp:21,
             from appcontrol.cpp:16:
/usr/include/boost/asio/detail/posix_fd_set_adapter.hpp:82:12: error: 'fd_set' does not name a type
   operator fd_set*()
            ^
/usr/include/boost/asio/detail/posix_fd_set_adapter.hpp:105:11: error: 'fd_set' does not name a type
   mutable fd_set fd_set_;
           ^
/usr/include/boost/asio/detail/posix_fd_set_adapter.hpp: In constructor 'boost::asio::detail::posix_fd_set_adapter::posix_fd_set_adapter()':
/usr/include/boost/asio/detail/posix_fd_set_adapter.hpp:42:14: error: 'fd_set_' was not declared in this scope
    FD_ZERO(&fd_set_);
             ^

1 个答案:

答案 0 :(得分:2)

感谢#cygwin IRC的帮助:

g++ -std=c++11 -Wall -g -D_XOPEN_SOURCE=500 test.cpp -o test.exe -lboost_system