本文介绍了的Andr​​oid NDK的x86_64的具有BCOPY和指数无参考的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想编译拉梅音效库与Android NDK为x86_64体系。我正在为未定义的引用下面的链接错误 BCOPY 首页

  JNI / libmp3lame / EN coder.c:471:错误:未定义的引用BCOPY
JNI / libmp3lame / EN coder.c:476:错误:未定义参照BCOPY
JNI / libmp3lame / id3tag.c:1125:错误:未定义的引用索引
JNI / libmp3lame / newmdct.c:1036:错误:未定义的引用BCOPY
JNI / libmp3lame / util.c:685:错误:未定义的引用BCOPY
 

在code编译成功用于x86和ARM架构。

所以,我通过NDK的库位挖,发现 BCOPY 首页在<$ C两个出口$ C> libc.so 适用于x86和ARM平台,而不是x86_64的(见下文 objdump的输出)。

  $&GT; objdump的-d的Andr​​oid NDK-r10d /平台/ Android为21 /弓臂/ usr / lib中/ libc.so | grep的BCOPY -A 6
0000b000&LT; BCOPY计算值:
    B000:e52db004推{FP}; (STR FP,[SP,#-4​​]!)
    B004:e28db000添加FP,SP,#0
    B008:e28bd000加SP,FP#0
    b00c:e8bd0800 LDMFD SP !, {FP}
    B010:e12fff1e BX LR


$&GT; objdump的-d的Andr​​oid NDK-r10d /平台/ Android为21 /拱86 / usr / lib中/ libc.so |的grep -A 6 BCOPY
00009fb0&LT; BCOPY计算值:
    9fb0:55推%EBP
    9fb1:89 E5 MOV%ESP,EBP%
    9fb3:5D弹出%EBP
    9fb4:C3 RET


$&GT; objdump的-d的Andr​​oid NDK-r10d /平台/ Android为21 /拱x86_64的/ usr / lib中/ libc.so |的grep -A 6 BCOPY
&LT;&LT;未找到&GT;&GT;
 

有什么想法?下面是我的Andr​​oid.mk和Application.mk文件。

Application.mk:

  APP_ABI:= x86_64的
APP_PLATFORM:=机器人-21
 

Android.mk:

  LOCAL_PATH:= $(叫我-DIR)

APP_PLATFORM:=机器人-21

包括$(CLEAR_VARS)

LOCAL_MODULE:= libmp3lame

LOCAL_SRC_FILES:= \
...&LT;列表的-.C-文件&GT; ...

LOCAL_LDLIBS + = -llog

包括$(BUILD_SHARED_LIBRARY)
 

解决方案

您可以用干净的 Application.mk 一行解决这个问题(的):

  APP_CFLAGS + = -DSTDC_HEADERS
 

为什么?

LAME 假定某些符号将通过的#include 是没有明确列入访问。但是,它也提供了一种信号,即明确纳入是必要的。

在我的分布,冲突性文件( machine.h id3tag.c )有这样的事情:

 的#ifdef STDC_HEADERS
#包括&LT; stdlib.h中&GT;
#包括&LT; string.h中&GT;
#ENDIF
 

这是需要触发,通过设置 STDC_HEADERS preprocessor变量块。上面的线,使用 -D 标记,告诉C编译器来创建它。

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'

The code successfully compiles for x86 and arm architectures.

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>>

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

Application.mk:

APP_ABI:=x86_64
APP_PLATFORM := android-21

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)
解决方案

You can fix this cleanly with a single line in Application.mk (docs):

APP_CFLAGS += -DSTDC_HEADERS

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.

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

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.

这篇关于的Andr​​oid NDK的x86_64的具有BCOPY和指数无参考的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-03 16:58