在“配置”中禁用 -Werror文件

发布于 2024-12-16 02:04:45 字数 890 浏览 4 评论 0原文

使用 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

千寻… 2024-12-23 02:04:45

Werror 是一个 GCC 参数,您无法删除它直接通过./configure。否则,类似 --disable-error 的选项将显示在帮助文本中。然而,这是可能的。

设置环境变量:

export CFLAGS="-Wno-error"

这是针对 C 编译器的。如果项目使用 C++,请执行以下操作:

export CXXFLAGS="-Wno-error"

在极少数情况下,项目不支持此变量,最后的手段是编辑 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:

export CFLAGS="-Wno-error"

That's for C compilers. If the project uses C++, do:

export CXXFLAGS="-Wno-error"

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).

紫瑟鸿黎 2024-12-23 02:04:45

看起来这个功能已经在 autotools 中存在很多年了:

./configure --disable-werror

不幸的是,我无法让以下特定情况发挥作用:

./configure --enable-wno-error=unused-value

如果可以的话,如果转义“=”符号,也许它可以工作。就像skim所说一样,人们仍然可以使用CFLAGS或<代码>CXXFLAGS。

It seems like the feature has been in autotools for many years:

./configure --disable-werror

Unfortunately, I wasn't able to get the following specific case to work:

./configure --enable-wno-error=unused-value

Maybe it could work if one escaped the '=' symbol, assuming it's possible. Like skim says, one can still use CFLAGS or CXXFLAGS.

開玄 2024-12-23 02:04:45

我必须在我的模块上使用 --disable-Werror (带有大写的 W)。虽然sudoman的答案上面建议使用--disable-werror(使用小写的w)。

它可能看起来像一个拼写错误,但它实际上取决于您特定的 configure 设置,特别是如果 configure 是由 autoconf 生成的。需要传递给 configure 脚本以禁用 Werror 的内容取决于构建系统的设置方式。

如果您的项目使用 autoconf- 中的 AX_COMPILER_FLAGS 选项archive 项目,则默认启用 -Werror

在另一个模块中,您可能会发现类似这样的内容:

+AC_ARG_ENABLE([werror],
+          AC_HELP_STRING([--disable-werror],
+                 [do not build with -Werror]),

因此您需要使用 --disable-werror

I had to use --disable-Werror (with an uppercase W) on my module. While sudoman's answer above suggests to use --disable-werror (with a lowercase w).

It may look like a typo, but it is actually dependent on your particular configure setup, especially if configure is generated by autoconf. What needs to be passed to the configure script to disable Werror 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:

+AC_ARG_ENABLE([werror],
+          AC_HELP_STRING([--disable-werror],
+                 [do not build with -Werror]),

And thus you would need to use --disable-werror.

静水深流 2024-12-23 02:04:45

这对我有用,在 Lubuntu 16.10 上编译curlpp:

./configure --disable-ewarning

This works for me, compiling curlpp on Lubuntu 16.10:

./configure --disable-ewarning
∞梦里开花 2024-12-23 02:04:45

我遇到了这个问题,结果发现我刚启动的 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文