停止 make 将警告视为错误

Stop make from treating warnings as errors

我正在尝试 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

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

我用谷歌搜索了如何阻止所有警告被视为错误;有人建议使用 -Wno-error 但这对我的情况没有影响。

这里怎么强制编译?

注意

Makefile 仅包含:

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

default: all

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

要清楚,这些是编译器选项,而不是 make 选项。

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

src/Makefile中有一行定义:

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

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