C ++ Qt-如何添加"-std = c ++ 11"到由qmake生成的makefile? [英] C++ Qt - How to add "-std=c++11" to the makefile which is generated by qmake?

查看:159
本文介绍了C ++ Qt-如何添加"-std = c ++ 11"到由qmake生成的makefile?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在用Qt开发程序.它的makefile是从.pro文件自动生成的.我需要使用一些代码,这些代码需要为g ++设置-std = c ++ 11标志.我应该在.pro中的哪个位置添加此标志? (每次我创建项目时,仅更改Makefile都是行不通的,因为它会被新生成的文件覆盖).

I'm developing a program in Qt. Its makefile is generated automatically from the .pro file. I need to use some code which need the -std=c++11 flag to be set up for g++. Where in .pro should I add this flag? (changing only the Makefile won't work since it gets overwritten by the newly generated one, each time I build the project).

推荐答案

您可能会很想插入特定的标记(您提到)

You may find it tempting to insert the specific flag (which you mention)

QMAKE_CXXFLAGS += -std=c++11

在您的.pro文件中,但这只会代表您插入该标志.

in your .pro file, but this will insert just that flag on your behalf.

那还不够.正确的方法是改为插入

That's insufficient. The right way is to insert instead

CONFIG += c++11

在您的.pro文件中.然后由qmake进行两个或三个必要的更改:

in your .pro file. Two or three necessary changes are then made by qmake:

    插入
  1. -std=c++11.
  2. 插入
  3. -stdlib=libc++.
  4. 如果您使用的是Mac,-mmacosx-version-min=10.6会变成-mmacosx-version-min=10.7. (也许在其他操作系统或操作系统版本上需要进行类似的更改.)
  1. -std=c++11 is inserted.
  2. -stdlib=libc++ is inserted.
  3. If you're on a Mac, -mmacosx-version-min=10.6 becomes -mmacosx-version-min=10.7. (Perhaps some similar change is necessary on other OSes or OS versions.)

( 1 中的类似问题, 2 .)

(A similar issue at 1 and 2.)

这篇关于C ++ Qt-如何添加"-std = c ++ 11"到由qmake生成的makefile?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆