boost:asio :: UnregisterWaitEx尚未声明

时间:2014-01-06 19:29:57

标签: c++ eclipse boost boost-asio

我正在尝试使用Win7上的MinGW使用#include <boost/asio.hpp>在eclipse中编译基本的客户端/服务器C ++程序,然后我得到:

Description Resource    Path    Location    Type '::UnregisterWaitEx' has not been declared zion        line 106, external location: C:\boost_1_55_0\boost\asio\detail\impl\win_object_handle_service.ipp   C/C++ Problem

我包含了路径C:\ boost_1_55_0以及库boost_system和boost_asio。

控制台输出:

 14:00:24 **** Incremental Build of configuration Debug for project boost_asio_test ****
Info: Internal Builder is used for build
g++ "-IC:\\boost_1_55_0\\" -O0 -g3 -Wall -c -fmessage-length=0 -o server.o "..\\server.cpp" 
In file included from C:\boost_1_55_0/boost/bind/bind.hpp:29:0,
                 from C:\boost_1_55_0/boost/bind.hpp:22,
                 from ..\server.cpp:11:
C:\boost_1_55_0/boost/bind/arg.hpp: In constructor 'boost::arg<I>::arg(const T&)':
C:\boost_1_55_0/boost/bind/arg.hpp:37:22: warning: typedef 'T_must_be_placeholder' locally defined but not used [-Wunused-local-typedefs]
         typedef char T_must_be_placeholder[ I == is_placeholder<T>::value? 1: -1 ];
                      ^
In file included from C:\boost_1_55_0/boost/asio/detail/win_object_handle_service.hpp:180:0,
                 from C:\boost_1_55_0/boost/asio/windows/object_handle_service.hpp:25,
                 from C:\boost_1_55_0/boost/asio/windows/basic_object_handle.hpp:27,
                 from C:\boost_1_55_0/boost/asio.hpp:108,
                 from ..\server.cpp:12:
C:\boost_1_55_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::detail::win_object_handle_service::implementation_type&, boost::asio::detail::win_object_handle_service::implementation_type&)':
C:\boost_1_55_0/boost/asio/detail/impl/win_object_handle_service.ipp:106:5: error: '::UnregisterWaitEx' has not been declared
     ::UnregisterWaitEx(impl.wait_handle_, INVALID_HANDLE_VALUE);
     ^
C:\boost_1_55_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&)':
C:\boost_1_55_0/boost/asio/detail/impl/win_object_handle_service.ipp:158:5: error: '::UnregisterWaitEx' has not been declared
     ::UnregisterWaitEx(impl.wait_handle_, INVALID_HANDLE_VALUE);
     ^
C:\boost_1_55_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&)':
C:\boost_1_55_0/boost/asio/detail/impl/win_object_handle_service.ipp:200:7: error: '::UnregisterWaitEx' has not been declared
       ::UnregisterWaitEx(wait_handle, INVALID_HANDLE_VALUE);
       ^
C:\boost_1_55_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&)':
C:\boost_1_55_0/boost/asio/detail/impl/win_object_handle_service.ipp:251:7: error: '::UnregisterWaitEx' has not been declared
       ::UnregisterWaitEx(wait_handle, INVALID_HANDLE_VALUE);
       ^
C:\boost_1_55_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&)':
C:\boost_1_55_0/boost/asio/detail/impl/win_object_handle_service.ipp:302:7: error: '::UnregisterWaitEx' has not been declared
       ::UnregisterWaitEx(wait_handle, INVALID_HANDLE_VALUE);
       ^
C:\boost_1_55_0/boost/asio/detail/impl/win_object_handle_service.ipp: In static member function 'static void boost::asio::detail::win_object_handle_service::wait_callback(PVOID, BOOLEAN)':
C:\boost_1_55_0/boost/asio/detail/impl/win_object_handle_service.ipp:402:5: error: '::UnregisterWaitEx' has not been declared
     ::UnregisterWaitEx(impl->wait_handle_, NULL);
     ^
In file included from C:\boost_1_55_0/boost/asio/detail/impl/win_tss_ptr.ipp:24:0,
                 from C:\boost_1_55_0/boost/asio/detail/win_tss_ptr.hpp:76,
                 from C:\boost_1_55_0/boost/asio/detail/tss_ptr.hpp:25,
                 from C:\boost_1_55_0/boost/asio/detail/call_stack.hpp:20,
                 from C:\boost_1_55_0/boost/asio/impl/handler_alloc_hook.ipp:19,
                 from C:\boost_1_55_0/boost/asio/handler_alloc_hook.hpp:80,
                 from C:\boost_1_55_0/boost/asio/detail/handler_alloc_helpers.hpp:21,
                 from C:\boost_1_55_0/boost/asio/detail/bind_handler.hpp:19,
                 from C:\boost_1_55_0/boost/asio/detail/wrapped_handler.hpp:18,
                 from C:\boost_1_55_0/boost/asio/io_service.hpp:24,
                 from C:\boost_1_55_0/boost/asio/basic_io_object.hpp:19,
                 from C:\boost_1_55_0/boost/asio/basic_socket.hpp:20,
                 from C:\boost_1_55_0/boost/asio/basic_datagram_socket.hpp:20,
                 from C:\boost_1_55_0/boost/asio.hpp:21,
                 from ..\server.cpp:12:
C:\boost_1_55_0/boost/asio/error.hpp: At global scope:
C:\boost_1_55_0/boost/asio/error.hpp:252:45: warning: 'boost::asio::error::system_category' defined but not used [-Wunused-variable]
 static const boost::system::error_category& system_category
                                             ^
C:\boost_1_55_0/boost/asio/error.hpp:254:45: warning: 'boost::asio::error::netdb_category' defined but not used [-Wunused-variable]
 static const boost::system::error_category& netdb_category
                                             ^
C:\boost_1_55_0/boost/asio/error.hpp:256:45: warning: 'boost::asio::error::addrinfo_category' defined but not used [-Wunused-variable]
 static const boost::system::error_category& addrinfo_category
                                             ^
C:\boost_1_55_0/boost/asio/error.hpp:258:45: warning: 'boost::asio::error::misc_category' defined but not used [-Wunused-variable]
 static const boost::system::error_category& misc_category
                                             ^
In file included from C:\boost_1_55_0/boost/asio/io_service.hpp:28:0,
                 from C:\boost_1_55_0/boost/asio/basic_io_object.hpp:19,
                 from C:\boost_1_55_0/boost/asio/basic_socket.hpp:20,
                 from C:\boost_1_55_0/boost/asio/basic_datagram_socket.hpp:20,
                 from C:\boost_1_55_0/boost/asio.hpp:21,
                 from ..\server.cpp:12:
C:\boost_1_55_0/boost/asio/detail/winsock_init.hpp:116:30: warning: 'boost::asio::detail::winsock_init_instance' defined but not used [-Wunused-variable]
 static const winsock_init<>& winsock_init_instance = winsock_init<>(false);
                              ^
In file included from ..\server.cpp:9:0:
C:\boost_1_55_0/boost/system/error_code.hpp:222:36: warning: 'boost::system::posix_category' defined but not used [-Wunused-variable]
     static const error_category &  posix_category = generic_category();
                                    ^
C:\boost_1_55_0/boost/system/error_code.hpp:223:36: warning: 'boost::system::errno_ecat' defined but not used [-Wunused-variable]
     static const error_category &  errno_ecat     = generic_category();
                                    ^
C:\boost_1_55_0/boost/system/error_code.hpp:224:36: warning: 'boost::system::native_ecat' defined but not used [-Wunused-variable]
     static const error_category &  native_ecat    = system_category();
                                    ^

14:00:27 Build Finished (took 2s.579ms)

我试着查看.ipp但找不到任何有用的东西。有些事情尚未宣布,但我不确定boost.org文档中的内容和内容并不突出。

我还没有尝试过实现任何其他的代码,因为它现在还没有编译,但可能需要做什么呢?

我现在的代码是一个使用winsock2的工作客户端/服务器,但我也希望它能在linux上运行。也许与winsock2代码和boost :: asio?

存在冲突

1 个答案:

答案 0 :(得分:5)

对于eclipse,添加符号:_WIN32_WINNT val:0x0601(或对于您的Windows系统:http://msdn.microsoft.com/en-us/library/windows/desktop/aa383745%28v=vs.85%29.aspx)以解决主要问题。

WSAPOLLFD问题归因于:https://github.com/mozilla/rust/issues/9246&amp;&amp; http://sourceforge.net/p/mingw/bugs/2049/通过添加以下内容进行修补:

typedef struct pollfd {
  SOCKET fd;
  short  events;
  short  revents;
} WSAPOLLFD, *PWSAPOLLFD, *LPWSAPOLLFD;

到winsock2.h。