【问题标题】:Stop make from treating warnings as errors停止 make 将警告视为错误
【发布时间】:2015-03-05 18:04:52
【问题描述】:

我正在尝试make 小代理服务器tcproxy:

user@localhost:tcproxy $ make
cd src && make all
make[1]: Entering directory '/home/user/Downloads/tcproxy/src'
    CC anet.o
In file included from /usr/include/sys/types.h:25:0,
                 from anet.c:33:
/usr/include/features.h:148:3: error: #warning "_BSD_SOURCE and _SVID_SOURCE are deprecated, use _DEFAULT_SOURCE" [-Werror=cpp]
 # warning "_BSD_SOURCE and _SVID_SOURCE are deprecated, use _DEFAULT_SOURCE"
   ^
cc1: all warnings being treated as errors
Makefile:26: recipe for target 'anet.o' failed
make[1]: *** [anet.o] Error 1
make[1]: Leaving directory '/home/user/Downloads/tcproxy/src'
Makefile:10: recipe for target 'all' failed
make: *** [all] Error 2

编译失败,因为all warnings are being treated as errors

它已经两年没有更新了,似乎警告只是来自被弃用的东西,但我希望它仍然可以工作。

我已经在 Google 上搜索过如何停止将所有警告视为错误;有人建议使用-Wno-error,但这对我的情况没有影响。

如何在此处强制编译?

注意

Makefile 只包含:

#
# tcproxy - Makefile
#
# Author: dccmx <dccmx@dccmx.com>
#

default: all

.DEFAULT:
    cd src && $(MAKE) $@

【问题讨论】:

  • 编译器将警告视为错误,而不是 make。 Make 只是观察编译器说它失败并且因为编译失败而没有继续。因此,您必须修改编译,以便编译器不会就已弃用的功能向您发出警告。对于必须支持多个系统的多个版本的人来说,这个警告并没有让他们的生活变得更轻松。
  • 相关的makefile是src目录下的,不是顶层目录。

标签: c linux compiler-errors makefile


【解决方案1】:

在src/Makefile 中有一行定义:

CFLAGS_GEN = -Wall -Werror -g $(CFLAGS)

删除-Werror,您收到的警告应该会被忽略。

【讨论】:

    【解决方案2】:

    需要明确的是,这些是编译器选项,而不是 make 选项。

    您需要找到 make 调用编译器时使用的选项。在您的 makefile 中查找选项 -Werror,并将其从它包含的任何变量中删除(可能是 CFLAGS 或一些变体)。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-01-05
      • 1970-01-01
      • 2012-01-13
      • 2022-08-03
      • 2010-11-05
      • 2013-07-06
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多