NDK 11链接器将警告视为错误 [英] NDK 11 linker is treating warnings as errors

查看:383
本文介绍了NDK 11链接器将警告视为错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用android ndk-11建立一个库,但出现链接器错误:

I'm trying to build a library with android ndk-11 and I'm getting a linker error:

arm-linux-androideabi/bin/ld: error: treating warnings as errors

如果我使用ndk-r10e,则不会出现此错误.

I do not get this error if I use ndk-r10e.

以V = 1运行ndk-build,我看到-Wl,--fatal-warnings被传递给链接器.我尝试将LOCAL_LDFLAGS:=-Wl,--no-fatal-warnings添加到我的Android.mk文件中,并且可以在链接器输出中看到它实际上已传递给链接器,但它是在之前 -Wl,--fatal-warnings传递的,所以它被忽略了.

Running ndk-build with V=1, I see that -Wl,--fatal-warnings is being passed to the linker. I've tried adding LOCAL_LDFLAGS:=-Wl,--no-fatal-warnings to my Android.mk file, and I can see in the linker output that it is in fact being passed to the linker, but it is passed before -Wl,--fatal-warnings, so it is being ignored.

警告来自第三方库,因此我不能只是重新编译它以修复警告(它们都是重定位是指废弃的部分"警告).我一直都看到这些警告,并且从未遇到任何问题.

The warnings are coming from a 3rd party library, so I can't just recompile it to fix the warnings (they are all 'relocation refers to discarded section' warnings). I've always seen these warnings and have never had any problems.

有人知道如何告诉ndk-11链接程序将警告视为错误吗?

Does anyone know how to tell the ndk-11 linker not to treat warnings as errors?

推荐答案

我在编写它时就发现了这一点,所以我想与大家分享解决方案.

I figured this out as I was writing it, so I thought I'd share the solution.

<NDK_ROOT>/build/core具有一堆运行ndk-build时使用的.mk文件.在build-binary.mk中,有一些新的(未记录的)检查可以定义的变量.对于这个特定的对象,有以下块:

<NDK_ROOT>/build/core has a bunch of .mk files that are used when running ndk-build. Inside build-binary.mk, there are a few new (undocumented) checks for variables you can define. For this particular one, there is the following block:

# We enable fatal linker warnings by default.
# If LOCAL_DISABLE_FATAL_LINKER_WARNINGS is true, we don't enable this check.
ifneq ($(LOCAL_DISABLE_FATAL_LINKER_WARNINGS),true)
  LOCAL_LDFLAGS += -Wl,--fatal-warnings
endif

在我的.mk文件中添加LOCAL_DISABLE_FATAL_LINKER_WARNINGS=true可以使错误消失.

Adding LOCAL_DISABLE_FATAL_LINKER_WARNINGS=true to my .mk file made the error go away.

这些文件中还定义了很多其他内容,因此,如果您突然遇到奇怪的构建错误,请查看其中是否有启用了新功能的内容.

There are lots of other things defined in these files, so if you're getting weird build errors all of a sudden, take a look in there to see if something new has been enabled.

这篇关于NDK 11链接器将警告视为错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆