在配置/制作时将编译标志附加到 CFLAGS 和 CXXFLAGS [英] Append compile flags to CFLAGS and CXXFLAGS while configuration/make

查看:39
本文介绍了在配置/制作时将编译标志附加到 CFLAGS 和 CXXFLAGS的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试构建的项目具有默认标志

The project that I am trying to build has default flags

CFLAGS = -Wall -g -O2

CXXFLAGS = -g -O2

我需要为这两个变量附加一个标志 -w(删除:'将所有警告视为错误')

I need to append a flag -w to both these variables (to remove: 'consider all warnings as errors')

我有办法解决,给

make 'CFLAGS=-Wall -g -O2 -w'; 'CXXFLAGS=-g -O2 -w'

运行./configure并静态修改Makefile

但我想在运行 configuremake

帖子在哪里添加 CFLAG,比如-std=gnu99,进入一个autotools项目方便地使用宏来实现这一点.

The post Where to add a CFLAG, such as -std=gnu99, into an autotools project conveniently uses a macro to achieve this.

推荐答案

你几乎说对了;为什么要加分号?

You almost have it right; why did you add the semicolon?

configure 行上做:

 ./configure CFLAGS='-g -O2 -w' CXXFLAGS='-g -O2 -w'

make 行上做:

 make CFLAGS='-g -O2 -w' CXXFLAGS='-g -O2 -w'

然而,这并不能真正消除将所有警告视为错误;删除所有警告.所以同时指定 -Wall-w 是没有意义的.如果您想保留警告但不将它们视为错误,请使用 -Wall -Wno-error 标志.

However, that doesn't really remove consider all warnings as errors; that removes all warnings. So specifying both -Wall and -w doesn't make sense. If you want to keep the warnings but not have them considered errors, use the -Wall -Wno-error flags.

或者,大多数默认启用 -Werrorconfigure 脚本也有一个标志,例如 --disable-werror 或类似的.运行 ./configure --help 看看是否有类似的东西.

Alternatively, most configure scripts which enable -Werror by default also have a flag such as --disable-werror or similar. Run ./configure --help and see if there's something like that.

这篇关于在配置/制作时将编译标志附加到 CFLAGS 和 CXXFLAGS的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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