Adding QMAKE_CXXFLAGS += -std=c++11 to .pro file in qt not working(on linux 12.04)

一曲冷凌霜 提交于 2019-12-10 14:59:23

问题


Compiler output:

[main.o] Error 1

cc1plus: error: unrecognized command line option '-std=c++11'


回答1:


The solution is to update your ancient gcc version on the system. In fact, I am quite surprised that you have such an old version on your 12.04 Ubuntu variant. It should have 4.6.3 by deault.

What you could try is c++0x instead of c++11 and see if that makes it work. You could also fire up the gcc manual by issuing man gcc and look for the precise option.

Also, while we are it, you could probably simply write this in your qmake project file instead of such raw configurations:

CONFIG += c++11



回答2:


As others already said in comments, this has nothing to do with Qt Creator version, but is caused by an g++ version that doesn't support C++11, for a little older g++ (but note that you need at least 4.3) the switch to enable the C++0x features implemented in the compiler is QMAKE_CXXFLAGS += -std=c++0x you can see the available features by following links in this page



来源:https://stackoverflow.com/questions/22925717/adding-qmake-cxxflags-std-c11-to-pro-file-in-qt-not-workingon-linux-12-0

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