How to use C++11 in your Qt Projects: Difference between revisions

From Qt Wiki
Jump to navigation Jump to search
No edit summary
(Cleanup)
Line 1: Line 1:
[[Category:HowTo]]
[[Category:HowTo]]


[toc align_right="yes" depth="3"]
At this moment (February 2015) qmake supports enabling C++11 (and now C++14) support via the <tt>CONFIG</tt> option in your <tt>.pro</tt> file. According to the qmake 3.0 manual that comes with Qt 5.4.0 ([http://doc.qt.io/qt-5/qmake-variable-reference.html qmake reference]) you just need to add


= How to use c+''11 in your qt projects?
CONFIG += c++11
 
At this moment (march 2014) Qt Creator doesn't add the necessary flags for you by default. You have to do it manually.
 
h2. In your pro file
 
add :
<code>QMAKE_CXXFLAGS''= -std=c+''0x // for GCC < 4.7
or
QMAKE_CXXFLAGS''= -std=c+''11 // for GCC >= 4.7</code>


or
or
<code>CONFIG''= c++11<code> =
== In Qt Creator build settings ==
you can use the build input fields :
Project > Build steps > qmake section >additional arguments


</code>“QMAKE_CXXFLAGS ''= -std=c''+0x”</code>
CONFIG += c++14


Don’t forget the “” in the input field.
''C++11 support is enabled. This option has no effect if the compiler does not support C++11. By default, support is disabled.''

Revision as of 20:28, 28 February 2015


At this moment (February 2015) qmake supports enabling C++11 (and now C++14) support via the CONFIG option in your .pro file. According to the qmake 3.0 manual that comes with Qt 5.4.0 (qmake reference) you just need to add

CONFIG += c++11

or

CONFIG += c++14

C++11 support is enabled. This option has no effect if the compiler does not support C++11. By default, support is disabled.