Jump to content
  • Advertisement
Sign in to follow this  

How to get Boost::asio working with MinGW

This topic is 1365 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I seem to be having trouble getting Boost::asio to work with MinGW with Eclipse.


I am using Boost version 1.50.


I have read around and am suprised very few people had this problem. I get this error when trying to use the Boost::asio Library:

"swprintf was not declared in this scope"


I got this error when I tried to use:

#define WIN32_WINNT 0x0501
#define WINVER 0x0501


in order to get around the UnregisteredWaitEx has not been declared error. Which seems unfortunate, because this makes the windows library for Windows XP the library to use. What if I want to use Windows 8 features?


Isn't there another way? I can get other Boost libraries to work, including Thread and XML.


I hear that often times these problems are due to ordering, but i've been switching things around and I still can't get rid of the error.


This is the order I am including:

#include <boost/bind.hpp>
#include <boost/asio.hpp>
#include <boost/thread/thread.hpp>


#include <windows.h>
#include <winsock2.h>
#include <glew.h>
#include <glfw3.h>


The libraries are in the same order.


How do you get Boost::asio to work? Preferably without having to downgrade to WindowsXP windows.h.

Share this post

Link to post
Share on other sites

Boost 1.57 is the latest, so you might want to upgrade.


I don't use the ASIO library myself, but in the revision history for ASIO, it says they fixed the error you are encountering in Boost 1.53.

Asio 1.8.3 / Boost 1.53 - "Changed to use _snwprintf to address a compile error due to the changed swprintf signature in recent versions of MinGW (#7373)"


If for some reason you are unable to upgrade to the latest Boost version, you could do a diff of the two ASIO versions (the latest and the outdated one you are currently using) and patch in the fixes yourself. But if you can, it'd probably be better just to upgrade the entire Boost library collection to the latest.

Share this post

Link to post
Share on other sites

Boost 1.57 is the latest, so you might want to upgrade.

Thanks :3. I got it working, but I still had to add #define WIN32_WINNT 0x0501 #define WINVER 0x0501. It just seems 'wrong' using a Windows XP version of the windows library in order for it to work. I wouldn't be able to use Windows 8 features, but then again I might need vs for that. Surely there has to be a way around this.

Edited by Solid_Spy

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!