在“配置”中禁用 -Werror文件
使用 Makefile 制作项目时,我收到此错误:
error: implicit declaration of function ‘fatal’ [-Werror=implicit-function-declaration]
cc1: all warnings being treated as errors
./configure --help
显示:
Optional Features:
--disable-option-checking ignore unrecognized --enable/--with options
--disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no)
--enable-FEATURE[=ARG] include FEATURE [ARG=yes]
--disable-dependency-tracking speeds up one-time build
--enable-dependency-tracking do not reject slow dependency extractors
--disable-gtktest do not try to compile and run a test GTK+ program
--enable-debug Turn on debugging
How can I Tell configure not include -Werror?
While making a project with Makefile, I get this error:
error: implicit declaration of function ‘fatal’ [-Werror=implicit-function-declaration]
cc1: all warnings being treated as errors
The ./configure --help
shows:
Optional Features:
--disable-option-checking ignore unrecognized --enable/--with options
--disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no)
--enable-FEATURE[=ARG] include FEATURE [ARG=yes]
--disable-dependency-tracking speeds up one-time build
--enable-dependency-tracking do not reject slow dependency extractors
--disable-gtktest do not try to compile and run a test GTK+ program
--enable-debug Turn on debugging
How can I tell configure not to include -Werror?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
Werror 是一个 GCC 参数,您无法删除它直接通过./configure。否则,类似
--disable-error
的选项将显示在帮助文本中。然而,这是可能的。设置环境变量:
这是针对 C 编译器的。如果项目使用 C++,请执行以下操作:
在极少数情况下,项目不支持此变量,最后的手段是编辑
configure.ac
文件并搜索-Werror
并将其从出现的字符串中删除(但要小心)。Werror is a GCC argument, and you cannot remove it directly via ./configure. Otherwise, an option like
--disable-error
would show up in the help text. However, it's possible.Set an environment variable:
That's for C compilers. If the project uses C++, do:
In the very rare case the project does not honor this variables, your last resort is to edit the
configure.ac
file and search for-Werror
and remove it from the string it occurs in (be careful though).看起来这个功能已经在 autotools 中存在很多年了:
不幸的是,我无法让以下特定情况发挥作用:
如果可以的话,如果转义“
=
”符号,也许它可以工作。就像skim所说一样,人们仍然可以使用CFLAGS或<代码>CXXFLAGS。
It seems like the feature has been in autotools for many years:
Unfortunately, I wasn't able to get the following specific case to work:
Maybe it could work if one escaped the '
=
' symbol, assuming it's possible. Like skim says, one can still useCFLAGS
orCXXFLAGS
.我必须在我的模块上使用
--disable-Werror
(带有大写的W
)。虽然sudoman的答案上面建议使用--disable-werror
(使用小写的w
)。它可能看起来像一个拼写错误,但它实际上取决于您特定的
configure
设置,特别是如果configure
是由autoconf
生成的。需要传递给configure
脚本以禁用Werror
的内容取决于构建系统的设置方式。如果您的项目使用
autoconf- 中的 AX_COMPILER_FLAGS 选项archive
项目,则默认启用-Werror
。在另一个模块中,您可能会发现类似这样的内容:
因此您需要使用
--disable-werror
。I had to use
--disable-Werror
(with an uppercaseW
) on my module. While sudoman's answer above suggests to use--disable-werror
(with a lowercasew
).It may look like a typo, but it is actually dependent on your particular
configure
setup, especially ifconfigure
is generated byautoconf
. What needs to be passed to theconfigure
script to disableWerror
depends on how the build system was setup.If your project uses the AX_COMPILER_FLAGS option from the
autoconf-archive
project, then by default-Werror
is enabled.In another module you may find something like this:
And thus you would need to use
--disable-werror
.这对我有用,在 Lubuntu 16.10 上编译curlpp:
This works for me, compiling curlpp on Lubuntu 16.10:
我遇到了这个问题,结果发现我刚启动的 EC2 实例运行 Ubuntu 20.04 (Focal Fossa)。
只需运行 sudo apt install gcc 就可以解决这个问题。
I ran into this problem, and it turned out that GCC was not installed on my freshly-started EC2 instance running Ubuntu 20.04 (Focal Fossa).
Simply running
sudo apt install gcc
fixed this issue for me.