使用Boost Asio时出错

时间:2015-06-03 13:16:03

标签: c++ boost mingw boost-asio codeblocks

每当我尝试包含<时,我都会在win_object_handle_service.ipp中获取“:: UnregisterWaitEx” boost / asio.hpp>进入我的代码。

目前我在Windows 8.1上使用Code :: Blocks,MinGW编译器(它没有与IDE捆绑在一起)。

Boost是在mingw include文件夹之外构建的,但它包含在项目设置中。

我得到的确切错误:

boost_1_58_0\boost\asio\detail\impl\win_object_handle_service.ipp||In member   function 'void       boost::asio::detail::win_object_handle_service::move_construct(boost::asio::deta il::win_object_handle_service::implementation_type&,  boost::asio::detail::win_object_handle_service::implementation_type&)':|
boost_1_58_0\boost\asio\detail\impl\win_object_handle_service.ipp|106|error: '::UnregisterWaitEx' has not been declared|
boost_1_58_0\boost\asio\detail\impl\win_object_handle_service.ipp||In member function 'void     boost::asio::detail::win_object_handle_service::move_assign(boost::asio::detail::win_object_handle_service::implementation_type&, boost::asio::detail::win_object_handle_service&, boost::asio::detail::win_object_handle_service::implementation_type&)':|
boost_1_58_0\boost\asio\detail\impl\win_object_handle_service.ipp|158|error: '::UnregisterWaitEx' has not been declared|
boost_1_58_0\boost\asio\detail\impl\win_object_handle_service.ipp||In member function 'void boost::asio::detail::win_object_handle_service::destroy(boost::asio::detail::win_object_handle_service::implementation_type&)':|
boost_1_58_0\boost\asio\detail\impl\win_object_handle_service.ipp|200|error: '::UnregisterWaitEx' has not been declared|
boost_1_58_0\boost\asio\detail\impl\win_object_handle_service.ipp||In member function 'boost::system::error_code boost::asio::detail::win_object_handle_service::close(boost::asio::detail::win_object_handle_service::implementation_type&, boost::system::error_code&)':|
boost_1_58_0\boost\asio\detail\impl\win_object_handle_service.ipp|251|error: '::UnregisterWaitEx' has not been declared|
boost_1_58_0\boost\asio\detail\impl\win_object_handle_service.ipp||In member function 'boost::system::error_code boost::asio::detail::win_object_handle_service::cancel(boost::asio::detail::win_object_handle_service::implementation_type&, boost::system::error_code&)':|
boost_1_58_0\boost\asio\detail\impl\win_object_handle_service.ipp|302|error: '::UnregisterWaitEx' has not been declared|
boost_1_58_0\boost\asio\detail\impl\win_object_handle_service.ipp|402|error: '::UnregisterWaitEx' has not been declared|
boost_1_58_0\boost\system\error_code.hpp|221|warning: 'boost::system::posix_category' defined but not used [-Wunused-variable]|
boost_1_58_0\boost\system\error_code.hpp|222|warning: 'boost::system::errno_ecat' defined but not used [-Wunused-variable]|
boost_1_58_0\boost\system\error_code.hpp|223|warning: 'boost::system::native_ecat' defined but not used [-Wunused-variable]|
boost_1_58_0\boost\asio\error.hpp|258|warning: 'boost::asio::error::system_category' defined but not used [-Wunused-variable]|
boost_1_58_0\boost\asio\error.hpp|260|warning: 'boost::asio::error::netdb_category' defined but not used [-Wunused-variable]|
boost_1_58_0\boost\asio\error.hpp|262|warning: 'boost::asio::error::addrinfo_category' defined but not used [-Wunused-variable]|
boost_1_58_0\boost\asio\error.hpp|264|warning: 'boost::asio::error::misc_category' defined but not used [-Wunused-variable]|
boost_1_58_0\boost\asio\detail\winsock_init.hpp|116|warning:    'boost::asio::detail::winsock_init_instance' defined but not used [-Wunused-variable]|

我尝试了什么:

  1. 将_WIN32_WINNT设置为0x0601(再添加一个警告)
  2. 按照here中的说明(没有任何反应)将struct pollfd添加到winsock2.h
  3. 链接的boost正则表达式,系统和线程库(或至少尝试过)
  4. 提前致谢,

    尼克

1 个答案:

答案 0 :(得分:0)

所以,我通过添加" -D_WIN32_WINNT = 0x0501 -DWINVER = 0x0501"来修复此错误。两个编译器链接器选项(在C :: B中)和#defines。 猜猜我添加了_WIN32_WINNT错误。