How to enable experimental C++11 concurrency features in MinGW?

To the best of my knowledge, MinGW does not support yet the new c++0x concurrency features (as of GCC 4.5). I remember reading a mailing list exchange in which it was pointed out that in MinGW the following ifdef from the thread header is not satisfied:

#if defined(_GLIBCXX_HAS_GTHREADS)

I guess this is somehow related to the way MinGW is built under Windows, whether it uses native threads or pthread, etc. In my code, I've written some minimal wrapping that uses Boost.thread instead of native c++0x threads when in Windows. The two interfaces are very similar and for many uses they can be swapped without issues.

EDIT: Thanks to Luc Danton for digging out the mailing list thread mentioned above:

http://comments.gmane.org/gmane.comp.gnu.mingw.user/33065


I am currently working on getting a GCC steamed up that uses the new mingw-w64 winpthreads library. This would enable a posix threading model in GCC, and work is underway to get it working like it should. Another mingw-w64 user has already got this functioning by hacking around (sensibly), but I'm trying to get it done in mainline GCC, without manual intervention after toolchain installation.

The present discussion can be followed here. I will update this answer once all rough edges have been smoothed out.

EDIT: Due to an upvote, this answer came to my attention. I have built an experimental GCC 4.7, which should work with std::thread, but only when linking statically (add -static to the link command). The announcement is here.


The C++0x library status page says it has been implemented, but you may need an SVN version to get everything listed on that page. This page looks like it would help you get a bleeding edge build.