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

Which C++ compiler currently has complete C++11 support on windows platform?

Microsoft compiler currently does not have full C++11 support (and it won't be added any time soon).
MinGW g++ (from mingw.org) does not support std::thread out of the box. It also can't compile Qt 4 sources (runs out of memory while building QtGuid4.dll, known workarounds didn't work for me).
I've wasted several days trying to make clang work on windows, managed to compile it, but couldn't enable c++11 support because it required libstdc++ which (I think) wasn't ported to windows platform at that moment. It also isn't supported by Qt 4.

What else is there? I've been working for C++03 for a long time, and I'd like to give new features a whirl, but I don't really want a tool that with incomplete support (that'll add extra headache while writing a code) or can run out of memory (on 8GB system) while linking a library.

I'm working on windows 7 64bit, and although having 64bit support would be nice, I'm mostly interested in 32bit applications, so ability to produce 64bit executables is optional.

Any suggestions?


Solution 1:

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:

  • Boost C++ Libraries;
  • Qt;
  • LLVM/Clang;
  • Google V8 JavaScript Engine;
  • ODB: C++ Object-Relational Mapping (ORM);
  • SQLite;
  • GLEW;
  • Vim;
  • ncurses;
  • etc...

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.

Solution 2:

Core language wise, Clang 3.3 and GCC 4.8.1 is fully C++11 conformance already(whether they're bug-free is yet another topic). Library(STL) wise, Clang 3.3(with libc++, but you know, libc++ is not yet usable in both windows and linux) is the only platform fully conform to C++11.

MSVC, the latest, Visual C++2013(currently RC, will be RTM in 2 days and general available in Nov 13) provide much better support for C++11 in both core language and STL, thought not complete yet. STL wise, afaik, it's complete.

I think that depends on what feature your codes really use. Have all C++11 new features been utilized? If Visual C++2013's feature set can satisfy you, try it. Otherwise, clang has already provide a windows port that can integrate to Visual Studio, and can link to native(msvc c++ runtime) library already(claimed), I think you can also give it a trial.

Addition: Visual C++11/14 conformance roadmap https://udta1g.blu.livefilestore.com/y2pMXBJL7l2a5UOf_pXnLXghSUhPWK8w5skFyc50SVFcMjVwa1guQnM6R0NNLN1buBUNPGbLBejpYXXBXSbqshQKKWVfQxvJjk2jGRPPbL-UBu7gaao4RxifZgPXY5ksdei/image1.png?psid=1