Boost::asio linking; identifier not found; C++

2019-07-21 17:46发布

问题:

I googled the error lines of my problem and got hardly any hits and I don't speak russian. I also found this, but it doesn't seem to help me.

This is my code

#include <iostream>
#include <boost/asio.hpp>
#include <boost/date_time/posix_time/posix_time.hpp>

int main() {

    boost::asio::io_service io;
    boost::asio::deadline_timer t(io,boost::posix_time::seconds(5));
    t.wait();
    std::cout << "Hello World" << std::endl;

    return 0;
}

These be my error messages:

1>------ Build started: Project: ConsoleApplication1, Configuration: Debug Win32 ------
1>  Main.cpp
1>c:\sdk\boost\asio\detail\impl\win_thread.ipp(52): error C2039: 'QueueUserAPC' : is not a member of '`global namespace''
1>c:\sdk\boost\asio\detail\impl\win_thread.ipp(52): error C3861: 'QueueUserAPC': identifier not found
1>c:\sdk\boost\asio\detail\impl\win_object_handle_service.ipp(374): error C3861: 'RegisterWaitForSingleObject': identifier not found
1>c:\sdk\boost\asio\detail\impl\win_object_handle_service.ipp(416): error C3861: 'RegisterWaitForSingleObject': identifier not found
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

Any insights would be appreciated, thanks!

EDIT Adding #include <Windows.h> before the headers changed the error messages to

1>c:\program files (x86)\windows kits\8.0\include\um\prsht.h(607): error C2146: syntax error : missing ';' before identifier 'hdr'
1>c:\program files (x86)\windows kits\8.0\include\um\prsht.h(607): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\program files (x86)\windows kits\8.0\include\um\windows.h(247): warning C4193: #pragma warning(pop) : no matching '#pragma warning(push)'
1>c:\sdk\boost\asio\detail\socket_types.hpp(22): fatal error C1189: #error :  WinSock.h has already been included

prsht.h: tracking that down lead me to find this:

typedef struct _PSHNOTIFY
{
    NMHDR hdr; //line 607 NMHDR is undefined.  
    LPARAM lParam;
} PSHNOTIFY, *LPPSHNOTIFY;

Not real sure where to go from here.