Windows C++ compiler with full C++11 support (should work with Qt) [closed]

First of all, see Status of Experimental C++11 Support in GCC 4.8. Only one proposal is not officially implemented yet. Then, have a look at Implementation Status of C++11 in libstdc++. As you can see some features are yet to be implemented. Nevertheless, we can state that C++11 support in GCC is more or less complete and usable.

Now, concerning Windows: probably definitely the best native (not Cygwin!) port of GCC, which I personally consider production-quality, is MinGW-w64. You can download it here. The current (at the time of writing) latest version is based on GCC 4.8.2. It already has support for std::thread. What’s more, it offers all the possible variations:

  • 64-bit targets;
  • 32-bit targets;
  • Win32 threads;
  • POSIX threads;
  • SEH exceptions;
  • DWARF exceptions;
  • SJLJ exceptions.

NOTE:
Be careful when choosing which distribution to download: for std::thread to be available, you need the one with POSIX threads.

Furthermore, I confirm that I’ve built Qt 4.8.4 and 4.8.5 myself numerous times and even targeting 64-bit with this toolchain. But that’s not all, here is a list of some highlights that I’ve personally built with MinGW-w64 so far:

I think being able to build such huge and diverse code bases as 64-bit targets with good old GCC for Windows is a miraculous achievement of MinGW-w64 developer team. It once again proves the quality of the toolchain.

Qt 5


I’ve recently built Qt 5.1.1 using MinGW-w64 4.8.2 targeting x64. All in all, it went pretty smooth, but there are a few minor issues which have to be patched before the build. I’ve gently collected all the required patches and automated the whole process of patching, building, and installing with a simple batch script. If you are interested, check out my Qt for Windows. The usage is so simple that I’ll skip commenting on it and simply let you guys read the batch script. Keep in mind that you need Unix’s patch.exe to apply the patches which you could get, for example, from MSYS or MSYS2 (see below). You can obtain Qt 5.1.1 source code here.

NOTE:
Does not seem reasonable to reinvent the wheel (maintaining personal build scripts and patches for Qt) anymore. MSYS2 (see below) now takes care of everything. That is if you need to rebuild Qt with different options and/or flags, then simply edit the corresponding PKGBUILD file locally and use the makepkg-mingw utility accordingly.

NOTE:
Actually, the Qt project officially recommends using MinGW-w64 and MSYS2.

About MSYS2


This was not asked directly, but I feel like adding it here as this is a sister project of MinGW-w64, and it’s very useful for anyone who has to develop native software for Windows using Unix-like environment.

Those of you who have ever used the original MSYS probably know how old it is. It hasn’t been improved for ages, and all the Unix utilities there are already terribly outdated.

Guys who provide builds of MinGW-w64 (listed above), now also provide builds of MSYS2 which you can download here. Recently, it came out of beta, so be sure to checkout the latest release. It’s built for both x86 and x64 architectures (with the MinGW-w64 toolchain itself). All the utilities are updated to their latest versions. For instance, you can already enjoy things like: Bash 4.2, Make 3.99, Git 1.8.4, and many more; which run natively on Windows out of the box!

NOTE:
Make sure to check their Wiki to have a smooth start.

A Short Story beyond MinGW-w64


The original MinGW was very slow on improvements, and its developers didn’t even consider adding 64-bit target generation support. One ambitious guy, Kai Tietz, took over it and forked it as his company needed to build 64-bit targets on Windows. That’s how MinGW-w64 project was born. Although the primary goal was to add 64-bit support, the developers have improved the toolchain in many aspects and addressed a great deal of other issues. Since then the MinGW-w64 project has grown and now is far ahead of MinGW in terms of quality. When MinGW-w64 proposed to MinGW to join the houses and work together, the developers of MinGW showed inadequate reaction and refused to cooperate. As a result, today there are 2 projects with similar name what sometimes causes confusion, but the differences in quality and support speak for themselves.

Leave a Comment