简体   繁体   中英

Error while using Boost Asio

I get "::UnregisterWaitEx is not declared" inside win_object_handle_service.ipp whenever I try to include < boost/asio.hpp > into my code.

Currently I am using Code::Blocks, MinGW compiler (which didn't come bundled with IDE) on Windows 8.1.

Boost is built outside of mingw include folder, though is included in project settings.

Exact errors I am getting :

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]|

What I've tried:

  1. Set _WIN32_WINNT to 0x0601 (Just one more warning added)
  2. Added struct pollfd to winsock2.h as instructed in here (nothing happens)
  3. Linked boost regex, system and thread libraries (or at least tried to)

Thanks in advance,

Nick

So, I fixed this error by adding "-D_WIN32_WINNT=0x0501 -DWINVER=0x0501" to both compilers linker options (in C::B) and #defines. Guess I added _WIN32_WINNT somehow wrong.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM