如何特别为特定模块指定gcc标志(CXXFLAGS)? [英] How to specify gcc flags (CXXFLAGS) particularly for a specific module?

查看:560
本文介绍了如何特别为特定模块指定gcc标志(CXXFLAGS)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

最近我正在构建一个新的NS3模块。在我的代码中,我使用了 C ++ 11(c ++ 0x)的新特性,我想添加一个gcc标志(CXXFLAGS) - std = c ++ 0x waf 配置系统。



我试过这个: CXXFLAGS = - std = c ++ 0xwaf configure ,然后构建它。但是,事实证明,一些现存的模块(如ipv4-address)与 c ++ 11 不兼容。因此,我想特别为我的新模块指定该标志,以便其他模块不会在c ++ 11上编译。



我试图将它添加到 中的wscript:

  def configure(conf):
conf.env .append_value('CXXFLAGS','-std = c ++ 0x')

第一次试用。

我该怎么做? @ drahnr的答案对香草水是正确的,它不适用于NS-3的构建系统,这显然是OP想要的。要将CXXFLAGS添加到NS-3程序中,可以将它们添加到构建对象中,而不是在配置阶段。



例如:

  def build(bld):
obj = bld.create_ns3_program('my_app',['core','other-dependencies'])
obj.source ='MyApplication.cpp'
obj.cxxflags = ['-std = c ++ 11']


I am building a new NS3 module recently. In my code, I use something new features of the C++11 (c++0x), I want to add a gcc flags (CXXFLAGS) "-std=c++0x" to the waf configuration system.

I tried to this: CXXFLAGS="-std=c++0x" waf configure, and then build it. However, it turns out that some of the exsiting modules such as ipv4-address is not compatible to c++11. Thus, I want to specify this flag particularly for my new module so that other modules won't be complied on c++11.

I tried to add this to the wscript in my new module:

def configure(conf):
    conf.env.append_value('CXXFLAGS', '-std=c++0x')

It fails as the first trial.

How can I do that?

解决方案

Although @drahnr's answer is correct for vanilla waf, it won't work with NS-3's build system, which is apparently what OP wants. To add CXXFLAGS to an NS-3 program, you can add them to the build object instead of in the configuration stage.

For example:

def build(bld):   
    obj = bld.create_ns3_program('my_app', ['core', 'other-dependencies'])
    obj.source = 'MyApplication.cpp'
    obj.cxxflags = ['-std=c++11']

这篇关于如何特别为特定模块指定gcc标志(CXXFLAGS)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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