Windows C ++编译器具有完整的C ++ 11支持(应该与Qt工作) [英] Windows C++ compiler with full C++11 support (should work with Qt)

查看:174
本文介绍了Windows C ++编译器具有完整的C ++ 11支持(应该与Qt工作)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

哪些C ++编译器目前在Windows平台上具有完成 C ++ 11支持?



Microsoft编译器目前没有完整的C ++ 11支持(且不会很快添加)。

MinGW g ++从mingw.org)不支持 std :: thread 开箱即用。它也不能编译Qt 4源(内存不足,而构建QtGuid4.dll,已知的解决方法没有为我工作)。

我浪费了几天试图让cl工作在窗口,管理编译它,但不能启用c ++ 11支持,因为它需要libstdc ++,(我认为)没有移植到Windows平台在那一刻。它也不被Qt 4支持。



还有什么?我一直在C ++ 03工作了很长时间,我想给新的功能旋风,但我不真的想要一个工具,不完全支持(这将增加额外的头痛,而写一个



我在Windows 7 64位上工作,虽然有64位的支持将是很好的,我最感兴趣的是32位应用程序,因此能够生成64位可执行文件是可选的。



有任何建议吗?

解决方案

首先,请参阅 状态GCC中的实验性C ++ 11支持4.8 。只有一个提案尚未正式实施。然后,查看 C的实施状态++ 11 in libstdc ++ 。正如你可以看到一些功能尚未实现。不过,我们可以声明GCC中的C ++ 11支持或多或少已经完成并且可用。



现在, > ( Cygwin / strong>!)端口 GCC ,我个人认为生产质量,是 MinGW-w64 。您可以下载 此处 。当前(写作时)的最新版本是基于GCC 4.8.2。它已经支持 std :: thread 。此外,它还提供了所有可能的变体:




  • 64位目标;

  • 位目标;

  • Win32线程;

  • POSIX线程;

  • SEH异常;

  • DWARF例外;

  • SJLJ例外。





选择要下载的发行版时要小心:对于 std :: thread 可用,您需要具有POSIX线程的发行版。



此外,我确认我已经多次构建Qt 4.8.4和4.8.5,甚至使用这个工具链来定位64位。但这不是全部,这里是一些亮点,我个人建立与MinGW-W64到目前为止:





我认为能够构建这样巨大和多样化的代码库作为64位目标与好的旧GCC为Windows是一个奇迹的成就MinGW-w64开发团队。它再次证明了工具链的质量。



Qt 5






我最近使用MinGW-w64 4.8.2指定x64版本建立了Qt 5.1.1。总而言之,它很顺利,但有一些小问题,必须在修补之前修补。我已经轻轻地收集所有必需的修补程序,并使用简单的批处理脚本自动完成修补,构建和安装的整个过程。如果您有兴趣,请查看我的 Qt for Windows 。用法如此简单,我将跳过对它的评论,只是让你们读的批处理脚本。请记住,您需要Unix的 patch.exe 才能应用您可以从MSYS或MSYS2(见下文)获得的补丁。您可以获取Qt 5.1.1源代码 此处



注意

似乎不合理的重新发明轮(维护个人构建脚本和补丁的Qt)了。 MSYS2(见下文)现在负责 一切< a> 。也就是说,如果您需要使用不同的选项和/或标志重建Qt,那么只需编辑相应的 PKGBUILD 文件,并使用 makepkg-mingw 实用程序。



注意

实际上,Qt项目 正式推荐使用MinGW-w64和MSYS2



关于MSYS2






这是没有直接问的,但我想添加它在这里,因为这是一个姊妹项目MinGW-w64,对于任何必须使用类Unix环境开发Windows的原生软件的任何人都非常有用。



那些曾经使用过原始 MSYS 可能知道它有多老。它还没有被改进的年龄,并且所有的Unix工具已经非常过时。



提供MinGW-w64(上面列出)的人,现在也提供 MSYS2 的构建,您可以下载 此处 。最近,它是测试版,所以一定要签出最新版本。它为x86和x64架构(使用MinGW-w64工具链本身)构建。所有实用程序都更新到其最新版本。例如,你可以享受像:Bash 4.2,Make 3.99,Git 1.8.4等等;



请务必检查其 a href =http://sourceforge.net/p/msys2/wiki/Home/ =nofollow> Wiki
以顺利开始。



超过MinGW-w64的短篇故事






原始 MinGW 的改进非常缓慢,其开发人员甚至不考虑添加64位目标生成支持。一个雄心勃勃的人,Kai Tietz接管了它,并且它的公司需要在Windows上构建64位目标。这就是MinGW-w64项目诞生的原因。虽然主要目标是添加64位支持,但开发人员在许多方面改进了工具链,并解决了大量其他问题。从那时起,MinGW-w64项目发展壮大,现在在质量方面远远领先于MinGW。当MinGW-w64提议MinGW 加入房子并一起工作时,MinGW的开发者显示不充分的反应,拒绝合作。因此,今天有两个名称相似的项目,有时会造成混乱,但质量和支持上的差异本身就是说话。


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?

解决方案

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.

这篇关于Windows C ++编译器具有完整的C ++ 11支持(应该与Qt工作)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆