本文介绍了适用于 x86_64 的 Android NDK 没有 bcopy 和 index 的参考的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用 Android NDK 为 x86_64 架构编译 Lame 声音库.对于对 bcopyindex 的未定义引用,我收到以下链接错误:

I am trying to compile Lame sound library with Android NDK for x86_64 architecture. I am getting the below link error for undefined references to bcopy and index:

jni/libmp3lame/encoder.c:471: error: undefined reference to 'bcopy'
jni/libmp3lame/encoder.c:476: error: undefined reference to 'bcopy'
jni/libmp3lame/id3tag.c:1125: error: undefined reference to 'index'
jni/libmp3lame/newmdct.c:1036: error: undefined reference to 'bcopy'
jni/libmp3lame/util.c:685: error: undefined reference to 'bcopy'

代码成功编译为 x86 和 arm 架构.

The code successfully compiles for x86 and arm architectures.

所以我稍微挖掘了一下 NDK 的库,发现 bcopyindex 都在 x86 和 arm 平台的 libc.so 中导出但不适用于 x86_64(见下文 objdump 输出).

So I digged through NDK's libs a bit and noticed that bcopy and index are both exported in libc.so for x86 and arm platforms but not for x86_64 (see below objdump outputs).

$> objdump -d android-ndk-r10d/platforms/android-21/arch-arm/usr/lib/libc.so | grep bcopy -A 6
0000b000 <bcopy>:
    b000:   e52db004 push   {fp}    ; (str fp, [sp, #-4]!)
    b004:   e28db000 add    fp, sp, #0
    b008:   e28bd000 add    sp, fp, #0
    b00c:   e8bd0800 ldmfd  sp!, {fp}
    b010:   e12fff1e bx lr


$> objdump -d android-ndk-r10d/platforms/android-21/arch-x86/usr/lib/libc.so | grep -A 6 bcopy
00009fb0 <bcopy>:
    9fb0:   55                   push   %ebp
    9fb1:   89 e5                   mov    %esp,%ebp
    9fb3:   5d                   pop    %ebp
    9fb4:   c3                   ret


$>  objdump -d android-ndk-r10d/platforms/android-21/arch-x86_64/usr/lib/libc.so | grep -A 6 bcopy
<<NOTHING FOUND>>

有什么想法吗?下面是我的 Android.mk 和 Application.mk 文件.

Any thoughts? Below are my Android.mk and Application.mk files.

Application.mk:

Application.mk:

APP_ABI:=x86_64
APP_PLATFORM := android-21

Android.mk:

Android.mk:

LOCAL_PATH := $(call my-dir)

APP_PLATFORM := android-21

include $(CLEAR_VARS)

LOCAL_MODULE        := libmp3lame

LOCAL_SRC_FILES     := 
...<list-of-.c-files>...

LOCAL_LDLIBS += -llog

include $(BUILD_SHARED_LIBRARY)

推荐答案

你可以在 Application.mk (docs):

APP_CFLAGS += -DSTDC_HEADERS

为什么?

LAME 假定某些符号无需通过 #include 显式包含即可访问.然而,它也提供了一种方式来表明明确包含是必要的.

Why?

LAME assumes that certain symbols will be accessible without explicit inclusion via #include. However, it also provides a way to signal that explicit inclusion is necessary.

在我的发行版中,有冲突的文件(machine.hid3tag.c)是这样的:

In my distribution, the conflictive files (machine.h and id3tag.c) have something like this:

#ifdef STDC_HEADERS
# include <stdlib.h>
# include <string.h>
#endif

这是您需要触发的块,通过设置 STDC_HEADERS 预处理器变量.上面带有 -D 标志的行告诉 C 编译器创建它.

This is the block you need to trigger, by setting the STDC_HEADERS preprocessor variable. The line above, with the -D flag, tells the C compiler to create it.

这篇关于适用于 x86_64 的 Android NDK 没有 bcopy 和 index 的参考的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-13 22:12