C++11 compiler for windows

2020-05-19 06:40发布

问题:

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. auto didn't work either.

I'm using Nokia's qtcreator which ships with 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.

回答1:

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...



回答2:

A special version of MinGW:

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

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

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

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.

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

F:\coding\MinGW\bin
F:\coding\MinGW\msys\1.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:

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



回答3:

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



回答4:

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

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 Express for C++ on Windows.



回答5:

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



回答6:

Scott Meyers maintains a webpage here:

C++11FeatureAvailability

The First link on the Webpage is:

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



回答7:

The Visual Studio 11 preview also supports lambdas.



回答8:

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.



回答9:

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



回答10:

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

  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.7 and 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).