52

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?

SigTerm
  • 26,089
  • 6
  • 66
  • 115
  • 1
    have you tried Nuwen's MingW distro? The compiler version is 4.8.1 and according to this: http://gcc.gnu.org/gcc-4.8/cxx0x_status.html it should have support for threads. – Adri C.S. Oct 17 '13 at 11:31
  • http://tdm-gcc.tdragon.net/ g++ 32/64 bit has thread support on Windows, http://nuwen.net/mingw.html has currently not. – René Richter Oct 17 '13 at 11:37
  • 8
    Sadly there is no compiler with full C++11 support for any platform – user1233963 Oct 17 '13 at 11:39
  • There's Intel C++ compiler, I don't know what's EDG's C++11 support status, but you can check. There's also `clang`. But I believe Microsoft compiler is by far the best for Windows. – Violet Giraffe Oct 17 '13 at 11:41
  • @VioletGiraffe Re MSVC: Except that it really lacks in C++11 support. – Angew is no longer proud of SO Oct 17 '13 at 11:46
  • @VioletGiraffe: ICC doesn't feature complete C++11 support either – user1233963 Oct 17 '13 at 11:49
  • 1
    @Angew: what exactly does MSVC 12.0 compiler (from VS 2013) lack in? – Violet Giraffe Oct 17 '13 at 11:49
  • @VioletGiraffe Implicit generation of move ctors/move assignment ops, for one. User-defined literals. `constexpr`. Unrestricted unions. Member function reference qualifiers. Thread-safe local statics. Inheriting constructors. Plus it has a very buggy preprocessor (as per discussions related to Boost.Preprocessor and the Chaos library). – Angew is no longer proud of SO Oct 17 '13 at 11:58
  • 1
    http://wiki.apache.org/stdcxx/C++0xCompilerSupport gives overview of current C++11 support in different compilers. – Greg Oct 17 '13 at 13:03
  • My experience is that actually no compiler has *full* c++11 support. Maybe all features are implemented and maybe a lot of is in the libraries but keep in mind the length of the bug lists! :-) – Klaus Oct 17 '13 at 14:07
  • @user1233963: I think clang claimed to have full C++11 support ... either on unix-likes or on MacOS. Not sure where. Also I'm not sure if this info is correct. If there's no full support anywhere, though, this is going to be very bad for C++ (IMO).... – SigTerm Oct 17 '13 at 14:32
  • @AdriC.S.: I *think* I hit the same out of memory error while linking QtGuid4 on nuwen. Not sure. – SigTerm Oct 17 '13 at 14:33
  • 1
    @Greg 's comparison table hasn't been updated for VC12 (VS2013) yet. To see what additional C++11 features have been added in MS's newest compiler you can look at their feature comparison table: http://msdn.microsoft.com/en-us/library/vstudio/hh567368%28v=vs.120%29.aspx – Dan Is Fiddling By Firelight Oct 17 '13 at 18:08

3 Answers3

65

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.

Alexander Shukaev
  • 16,674
  • 8
  • 70
  • 85
  • 10
    They should have picked a completely new name. MinGW built off work done by Cygwin. MinGW-w64 built off MinGW. At the end of the day, it's Win64-GCC, should haven just called it that. – Warren P Oct 17 '13 at 13:28
  • Sounds very promising, I'll check it out. – SigTerm Oct 17 '13 at 14:34
  • 1
    great. just note: " so we can state that C++11 support in GCC is sort of complete." That is not the whole story as there are a lot of standard library features/components missing demanded by C++11. – Johan Lundberg Oct 17 '13 at 17:07
  • @Johan Lundberg: Good catch, done. – Alexander Shukaev Oct 17 '13 at 17:22
  • Last time I checked (about two months ago), the `std::random_device` of MinGW-w64 is broken. Just a reminder for anyone who needs ``. – Siyuan Ren Nov 11 '13 at 08:50
  • @AlexanderShukaev: Can you use MinGW to compile/build production release of existing Chromium browser open source? –  Jan 06 '17 at 11:02
  • MinGW-w64: the installer has _all_ buttons set to 'install', one has to manually deselect them, if he just wants gcc. hundreds of buttons. Holocaust. – Nils Lindemann May 18 '17 at 01:44
  • @Nils, never felt like I have to use the installer admittedly. I guess Unixish people strive to avoid Windows installers as much as possible. It's in their blood. `;)` – Alexander Shukaev May 18 '17 at 06:09
8

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

JC_Yang
  • 91
  • 4
0

Clang has complete support of windows (modulo Windows standard library bugs in libc++) You can download an "official" windows build of clang 3.3 from here: http://www.llvm.org/builds/

It doesn't include libc++ so you'll need to download either that or your standard library of choice. I'd recommend using libc++ if possible, as this is currently the most complete library implementation, although I don't know how well it works on windows.

Richard Matheson
  • 1,125
  • 10
  • 24
  • 2
    "I don't know how well it works on windows." As far as I know, it doesn't work on windows. I've tried to build it, and if you check windows status for libc++, it'll be full of "needs investigation". Also my attempt to compile Qt 4 with clang has failed. – SigTerm Oct 17 '13 at 14:28