<command-line>:0:0: error: "_FORTIFY_SOURCE" redefined [-Werror]

本文介绍了在Ubuntu 12.04 32位环境下编译Android 4.0.3包时遇到的_FORTIFY_SOURCE编译错误,并提供了详细的解决方案。通过修改源码目录下的HOST_linux-x86.mk文件,将HOST_GLOBAL_CFLAGS设置为HOST_GLOBAL_CFLAGS+=-U_FORTIFY_SOURCE-D_FORTIFY_SOURCE=0,可以解决该错误。

这两天在ubuntu12.04 32位上编译android4.0.3包,发现的如标题的错误。

错误打印如下:

host C++: obbtool <= frameworks/base/tools/obbtool/Main.cpp
<command-line>:0:0: error: "_FORTIFY_SOURCE" redefined [-Werror]
<built-in>:0:0: note: this is the location of the previous definition
cc1plus: all warnings being treated as errors
make: *** [out/host/linux-x86/obj/EXECUTABLES/obbtool_intermediates/Main.o] Error 1

上网查了查,解决方法如下:

修改源码目录下/build/core/combo/HOST_linux-x86.mk文件:

将以下语句

HOST_GLOBAL_CFLAGS += -D_FORTIFY_SOURCE=0

修改为

HOST_GLOBAL_CFLAGS += -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=0

ATTENTION:
There is a SPACE between the -U_FORTIFY_SOURCE and -D_FORTIFY_SOURCE

In file included from c-ctype.c:1: ./config.h:100: warning: "_FORTIFY_SOURCE" redefined 100 | # define _FORTIFY_SOURCE 2 | <command-line>: note: this is the location of the previous definition In file included from gl_avltree_oset.c:18: ./config.h:100: warning: "_FORTIFY_SOURCE" redefined 100 | # define _FORTIFY_SOURCE 2 | In file included from binary-io.c:1: ./config.h:100: warning: "_FORTIFY_SOURCE" redefined 100 | # define _FORTIFY_SOURCE 2 | <command-line>: note: this is the location of the previous definition <command-line>: note: this is the location of the previous definition CC c-stack.o In file included from c-stack.c:36: ./config.h:100: warning: "_FORTIFY_SOURCE" redefined 100 | # define _FORTIFY_SOURCE 2 | <command-line>: note: this is the location of the previous definition CC c-strcasecmp.o In file included from /usr/include/signal.h:328, from ./signal.h:52, from c-stack.c:49: c-stack.c:55:26: error: missing binary operator before token "(" 55 | #elif HAVE_LIBSIGSEGV && SIGSTKSZ < 16384 | ^~~~~~~~ In file included from c-strcasecmp.c:17: ./config.h:100: warning: "_FORTIFY_SOURCE" redefined 100 | # define _FORTIFY_SOURCE 2 | <command-line>: note: this is the location of the previous definition make[5]: *** [Makefile:1915: c-stack.o] Error 1 make[5]: *** Waiting for unfinished jobs.... make[4]: *** [Makefile:1674: all] Error 2 make[3]: *** [Makefile:1572: all-recursive] Error 1 make[2]: *** [Makefile:1528:all] 错误 2 make[1]: *** [package/pkg-generic.mk:230:/home/sed/buildroot-2017.08/output/build/host-m4-1.4.18/.stamp_built] 错误 2 make: *** [Makefile:79:_all] 错误 2
最新发布
05-26
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值