2

我正在运行一个简单的示例,但无法编译代码。

我在 Windows 7 机器上使用 minGW、netbeans 和 boost。

起初我得到:

g++    -c -g -MMD -MP -MF build/Debug/MinGW-Windows/main.o.d -o build/Debug/MinGW-Windows/main.o main.cpp
main.cpp:12:26: fatal error: boost/asio.hpp: No such file or directory
 #include <boost/asio.hpp>

所以,我猜是一个链接错误。为了解决这个问题,我复制了

C:\boost\boost_1_54_0\boost

C:\MinGW\include\boost

我怀疑这是对的,但现在我收到以下错误:

g++    -c -g -MMD -MP -MF build/Debug/MinGW-Windows/main.o.d -o build/Debug/MinGW-Windows/main.o main.cpp
c:\mingw\include\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&)':
In file included from c:\mingw\include\boost\asio\detail\win_object_handle_service.hpp:180:0,
                 from c:\mingw\include\boost\asio\windows\object_handle_service.hpp:25,
                 from c:\mingw\include\boost\asio\windows\basic_object_handle.hpp:27,
                 from c:\mingw\include\boost\asio.hpp:108,
                 from main.cpp:12:
c:\mingw\include\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:\mingw\include\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:\mingw\include\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:\mingw\include\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:\mingw\include\boost\asio\detail\impl\win_object_handle_service.ipp:200:7: error: '::UnregisterWaitEx' has not been declared
       ::UnregisterWaitEx(wait_handle, INVALID_HANDLE_VALUE);
       ^
c:\mingw\include\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:\mingw\include\boost\asio\detail\impl\win_object_handle_service.ipp:251:7: error: '::UnregisterWaitEx' has not been declared
       ::UnregisterWaitEx(wait_handle, INVALID_HANDLE_VALUE);
       ^
c:\mingw\include\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:\mingw\include\boost\asio\detail\impl\win_object_handle_service.ipp:302:7: error: '::UnregisterWaitEx' has not been declared
       ::UnregisterWaitEx(wait_handle, INVALID_HANDLE_VALUE);
       ^
c:\mingw\include\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:\mingw\include\boost\asio\detail\impl\win_object_handle_service.ipp:402:5: error: '::UnregisterWaitEx' has not been declared
     ::UnregisterWaitEx(impl->wait_handle_, NULL);
     ^
make.exe[2]: *** [build/Debug/MinGW-Windows/main.o] Error 1
make.exe[2]: Leaving directory `/c/Users/Jeff/Documents/NetBeansProjects/CppApplication_2'
make.exe[1]: *** [.build-conf] Error 2
make.exe[1]: Leaving directory `/c/Users/Jeff/Documents/NetBeansProjects/CppApplication_2'
make.exe": *** [.build-impl] Error 2


BUILD FAILED (exit value 2, total time: 12s)
4

1 回答 1

4

尝试把你的命令行

-D_WIN32_WINNT=0x0601 -DWINVER=0x0601

或者

-D_WIN32_WINNT=0x0501 -DWINVER=0x0501

Windows 版本

于 2013-09-13T20:39:21.503 回答