Compilation of C++14 in qtcreator

空扰寡人 提交于 2019-12-05 06:16:50

Instead of:

CONFIG += -std=c++14

Use:

CONFIG += c++14
Orient

You can fix it radically. By changing config files.

First of all you need the library path, used in your project. The path you can determine looking at Projects panel (Ctrl + 5) and remembering the name of a "Kit" over the (Build|Run) buttons, then follow the Tools -> Options -> Build & Run -> Kits, select the "Kit" you remember previously, then you can see Qt version: line contents, after that on Qt versions tab you can see the corresponding full library path you need. In my case I see /usr/local/Qt-5.4.1/.

In /usr/local/Qt-5.4.1/mkspecs/common/g++-base.conf file (you may have another path for Qt library installed), you can change QMAKE_CXXFLAGS_CXX11 or QMAKE_CXXFLAGS_CXX14 (if any) variable to whatever you want (say, to -std=gnu++1z).

For clang the path became /usr/local/Qt-5.4.1/mkspecs/common/clang.conf in my case.

For some other targets/compilers you may should to follow Tools -> Options -> Build & Run -> Kits -> (select Kit you use) -> (look at 'Qt mkspec:' line at bottom) then find in /usr/local/Qt-5.4.1/mkspecs/*/qmake.conf (where * is Qt mkspec: line contents) and in all included *.conf files a string QMAKE_CXXFLAGS_CXX11 or QMAKE_CXXFLAGS_CXX14, that you need. Then change its value appropriately.

Then of course you need to use CONFIG += c++11 or CONFIG += c++14, as Jon Harper mentioned in his answer.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!