适用于 Windows 的 C++11 编译器

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/7966489/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-28 17:48:52  来源:igfitidea点击:

C++11 compiler for windows

c++compiler-constructionc++11

提问by nikhil

I was just watching a few videos on Channel9. I found things like lambdas really cool. when I tried to copy the example, it failed. autodidn't work either.

我只是在 Channel9 上看一些视频。我发现像 lambdas 这样的东西真的很酷。当我试图复制这个例子时,它失败了。auto也没有用。

I'm using Nokia's qtcreator which ships with gcc-4.4.0.

我正在使用诺基亚的 qtcreator,它随 gcc-4.4.0 一起提供。

I wanted to know which compiler has the fun features implemented so I could play around and learn. I'm not anti MS or anyhting so I don't mind trying Visual Studio if it has those features.

我想知道哪个编译器实现了有趣的功能,以便我可以玩玩和学习。我不反对 MS 或任何东西,所以如果 Visual Studio 具有这些功能,我不介意尝试它。

采纳答案by DejanLekic

Nearly all C++11 features are implemented in the GCC 4.6.x . A good place to get latest GCC builds (MinGW) is the TDM website - http://tdm-gcc.tdragon.net/download. It should be easy to replace your current GCC with TDM GCC by overwriting files...

几乎所有 C++11 特性都在 GCC 4.6.x 中实现。获取最新 GCC 版本 (MinGW) 的好地方是 TDM 网站 - http://tdm-gcc.tdragon.net/download。通过覆盖文件将您当前的 GCC 替换为 TDM GCC 应该很容易...

回答by Johan Lundberg

A special version of MinGW:

一个特殊版本的 MinGW:

MinGW-Builds gives you everything gcc offers (currently 4.7.2)

MinGW-Builds 为您提供 gcc 提供的一切(目前为 4.7.2)

That is: Including support for std::thread, std::async, std::future and friends.

即:包括对 std::thread、std::async、std::future 和朋友的支持。

As far as I know that's by far the most complete C++11 you can get on Windows.

据我所知,这是迄今为止您可以在 Windows 上获得的最完整的 C++11。

You just get the MinGW-build binaries here. Unlike other gcc-based installations it supports posix threads, which are currently key to getting the gcc support for C++11 threads and friends working on Windows.

您只需在此处获取MinGW-build 二进制文件。与其他基于 gcc 的安装不同,它支持 posix 线程,这是当前获得对 C++11 线程和在 Windows 上工作的朋友的 gcc 支持的关键。

Extract the directory mingw to any location and add the following two paths to your PATH environment variable: (well, change F:\coding ...)

将目录 mingw 解压到任意位置,并将以下两个路径添加到您的 PATH 环境变量中:(好吧,更改 F:\coding ...)

F:\coding\MinGW\bin
F:\coding\MinGW\msys.0\bin

Add both, separated by semi colon. You will need to log out or reboot. To verify that you got it right, you can open a command prompt, and write

添加两者,以分号分隔。您将需要注销或重新启动。为了验证你做对了,你可以打开一个命令提示符,然后写

g++ --version 

You should get a response like this, mentioning MinGW-builds:

你应该得到这样的回应,提到 MinGW-builds:

g++ (Built by MinGW-builds project) 4.7.2 
Copyright (C) 2012 Free Software Foundation, Inc. ...

I wrote a more complete instruction for getting this going with Eclipse, here: http://scrupulousabstractions.tumblr.com/post/36441490955/eclipse-mingw-builds

我写了一个更完整的说明来使用 Eclipse,在这里:http: //scrupulousabstractions.tumblr.com/post/36441490955/eclipse-mingw-builds

回答by Andrzej

For playing around and learning C++11 on Windows, I recommend MinGW Distroby Stephan T. Lavavej. The newest version contains GCC 4.8.2 and Boost 1.55.0.

为了在 Windows 上玩耍和学习 C++11,我推荐Stephan T. Lavavej 的MinGW Distro。最新版本包含 GCC 4.8.2 和 Boost 1.55.0。

回答by Jason

Take a look at MinGW-w64if you're looking for a gcc-compatible compiler on Windows that supports a number of C++11 features.

如果您正在 Windows 上寻找支持许多 C++11 功能的 gcc 兼容编译器,请查看 MinGW-w64

Also if you're just looking for lambas and auto, as well as some other C++11 features like decltype, etc., (again, not as many feature are implemented compared to the latest stable gcc branch) then you can also use the free Visual Studio 2010 Expressfor C++ on Windows.

此外,如果您只是在寻找 labas 和 auto,以及其他一些 C++11 功能,例如decltype等(同样,与最新的稳定 gcc 分支相比,实现的功能没有那么多),那么您也可以使用适用于 Windows 上的 C++ 的免费 Visual Studio 2010 Express

回答by Simon

See herefor an overview of the compilers and the supported C++11 features.

有关编译器和支持的 C++11 功能的概述,请参见此处

回答by Alok Save

Scott Meyers maintains a webpage here:

Scott Meyers 在这里维护一个网页:

C++11FeatureAvailability

C++11功能可用性

The First link on the Webpage is:

网页上的第一个链接是:

Apache Wiki Overview of C++11 Support in Several Compilersis what you should have a look at.It doccuments in detail C++11 features supported by all popular compilers.

Apache Wiki Overview of C++11 Support inMultipleCompilers是您应该查看的内容。它详细记录了所有流行编译器支持的 C++11 特性。

回答by Amit G.

Visual Studio 2017 has support in C++11, C++14, & C++17. + some of the Modern C++ "experimental" modules. If you decide on Visual Studio, you set the C++ standard at the project properties. C++11 is by default, but you can set it to C++14, C++17, or latest draft.

Visual Studio 2017 支持 C++11、C++14 和 C++17。+ 一些现代 C++“实验”模块。如果您决定使用 Visual Studio,请在项目属性中设置 C++ 标准。默认情况下为 C++11,但您可以将其设置为 C++14、C++17 或最新草案。

回答by Vlad

As regards g++, C++0x feature support should be detailed here: C++0x/C++11 Support in GCC - GNU Project - Free Software Foundation (FSF)

关于 g++,C++0x 功能支持应在此处详细说明:GCC 中的 C++0x/C++11 支持 - GNU 项目 - 自由软件基金会 (FSF)

回答by mmisu

If you want to test most of the C++11 syntax using a Windows machine you have two options:

如果您想使用 Windows 机器测试大部分 C++11 语法,您有两个选择:

  1. Install Cygwin and compile from sources gcc-4.7(latest snapshot) and clang++with libstdc++. However it is not guaranteed that this will work.

  2. Safest bet: Install a modern Linux (such as Ubuntu if you are a Linux newbie) in a virtual machine (VirtualBox is a free virtual machine application) and in this virtual machine compile gcc-4.7and clang++. I was able to successfully compile both of them on Ubuntu 11.10 following the instructions from this website.

  3. Best option, as of 2014, is to use Visual Studio 2013 updated with the latest CTP (this will work even for the Express edition).

  1. 安装Cygwin和从源代码编译gcc-4.7(最新的快照),并clang++libstdc++。但是,不能保证这会起作用。

  2. 最安全的选择:在虚拟机(VirtualBox 是一个免费的虚拟机应用程序)中安装现代 Linux(例如 Ubuntu,如果你是 Linux 新手),并在这个虚拟机中编译gcc-4.7clang++. 我能够按照本网站的说明在 Ubuntu 11.10 上成功编译它们。

  3. 截至 2014 年,最佳选择是使用更新为最新 CTP 的 Visual Studio 2013(这甚至适用于 Express 版本)。