using boost.asio with wx widgets

Hi: I'm trying to use wx widgets with boost.asio. I'm including wx.h in the main header file-which is not being included in the header I'm concerned with now. Wx.h includes windows.h and therefore winsock.h. I'm getting the error 1189 #error : winsock.h has already been included. I've defined win32_lean_and_mean before including boost/asio.hpp. I've also tried including wx.h before asio.hpp in the header I'm dealing with now, this makes no difference I still get the same error. Has anyone got any other ideas? Any help appreciated. Regards Sean.

2011/3/20 Sean Farrow
Hi:
I’m trying to use wx widgets with boost.asio.
I’m including wx.h in the main header file—which is not being included in the header I’m concerned with now. Wx.h includes windows.h and therefore winsock.h.
I’m getting the error 1189 #error : winsock.h has already been included. I’ve defined win32_lean_and_mean before including boost/asio.hpp.
I’ve also tried including wx.h before asio.hpp in the header I’m dealing with now, this makes no difference I still get the same error.
Has anyone got any other ideas?
Any help appreciated.
Regards
Sean.
I have used wx together with boost, but not together with asio. However, I have a wild guess what you can try, assuming you aren't going to use sockets from wx. Try not including wx.h, but only precisely the wx files you need - this could help... Regards Kris

On Sun, Mar 20, 2011 at 6:53 AM, Sean Farrow
I’m trying to use wx widgets with boost.asio.
We use ASIO and wxWidgets together extensively. IME, you *must* include boost/asio.hpp *before* any wx includes (i.e. before including windows.h). Otherwise, the wrong version of winsock will be defined by windows.h, giving compile errors. Additionally, you may need to define WX_LEAN_AND_MEAN (as opposed to WIN32_LEAN_AND_MEAN) and NOMINMAX. Given the error you're reporting, I suspect you need to define WX_LEAN_AND_MEAN. Not sure if there is another work-around. Jon
participants (3)
-
Jonathan Franklin
-
Krzysztof Czainski
-
Sean Farrow