How to Program C++11 Using Qt5?
QMAKE_CXXFLAGS += -std=c++0x
Results in an error because you're not using the MinGW compiler. "D9002: Ignoring unknown option -std=c++0x
" is an error from the MSVC compiler.
In QtCreator, go to the projects tab(on the left) and change the toolchain you're using. If it hasn't auto-detected MinGW, you're going to have to add it yourself by clicking on the manage button.
How to enable C++11 in Qt Creator?
According to this site add
CONFIG += c++11
to your .pro file (see at the bottom of that web page). It requires Qt 5.
The other answers, suggesting
QMAKE_CXXFLAGS += -std=c++11
(or QMAKE_CXXFLAGS += -std=c++0x
)
also work with Qt 4.8 and gcc / clang.
Building Qt project for C++11 standard
Use the qmake project file, add this line: QMAKE_CXXFLAGS += -std=c++11
LE: also 4.6.3 might not support C++11 (as far as i know 4.7 and higher support -std=c++11) so the option for the 0x features implemented might be: QMAKE_CXXFLAGS += -std=c++0x
Enable C++11 Support on Qt with MinGW or VS2012 Compilers
In .pro file, add the line
CONFIG += c++11
Qt Creator 2.6.1 + Qt 5 + C++11 + MSVC2010 compiler
You can simply put:
CONFIG += c++11
in your .pro file. But upgrading your compiler to a recent g++
or clang
is highly recommended.
Related Topics
How to Use the Mingw Gdb Debugger to Debug a C++ Program in Windows
How to Play or Open *.Mp3 or *.Wav Sound File in C++ Program
How to Deal with "Signed/Unsigned Mismatch" Warnings (C4018)
What's the Difference Between the Win32 and _Win32 Defines in C++
Why Are Bitwise Shifts (<< and >>) Used for Cout and Cin
Refreshing the Auto Complete (Intellisense) Database in Visual Studio
Is It Legal to Use the Increment Operator in a C++ Function Call
Calling Functions in a Dll from C++
C++11 Implementation of Spinlock Using <Atomic>
What Exactly Is a 'Side-Effect' in C++
What Happens If 'Throw' Fails to Allocate Memory for Exception Object
Visual Studio 2015 Run-Time Dependencies or How to Get Rid of Universal Crt