c++ - boost:asio::UnregisterWaitEx 尚未声明

标签 c++ eclipse boost boost-asio

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

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 文档中没有任何内容。

我实际上还没有尝试实现任何其他 boost 代码,因为它现在还没有编译,但这可能是需要做的?

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

最佳答案

对于 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 && http://sourceforge.net/p/mingw/bugs/2049/通过添加以下内容进行修补:

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

到winsock2.h。

关于c++ - boost:asio::UnregisterWaitEx 尚未声明,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20957727/

相关文章:

c++ - 什么是 sa_family_t

java - 如何计算标签的最大拟合字体大小?

Eclipse - 添加服务器 - 当我选择特定的 Tomcat(例如 tomcat8)时,下一步按钮被禁用

c++ - boost编译标志iw是什么意思?

c++ - 自动更新软件; FTP 是一个好的选择吗?

c++ - 如何使用 C++ 中的源代码扩展 .lib?

c++ - 测试某物是否是对另一物的引用

c++ - C++20 中是否有 boost::irange 等价物?

c++ - "for(;;)"比 "while (true)"快吗?如果不是,人们为什么要使用它?

java - 缺少 Artifact com.oracle :ojdbc7 in eclipse