简体   繁体   English

在Android NDK应用中使用第三方.a库

[英]Using a third party .a library in Android ndk app

We are trying to use a third party .a static library in our Android app. 我们正在尝试在我们的Android应用中使用第三方.a静态库。 The .a lib is built for x86 and we used it with a PC linux box without problem. .a库是为x86构建的,我们将其与PC linux盒一起使用完全没有问题。

Then we try to use it on Android with this Android.mk: 然后,我们尝试通过以下Android.mk在Android上使用它:

LOCAL_PATH:= $(call my-dir)

# first lib, which will be built statically
#
include $(CLEAR_VARS)

LOCAL_MODULE    := libtwolib-first
LOCAL_SRC_FILES := rwl.a
LOCAL_MODULE_SUFFIX := .a

include $(PREBUILT_STATIC_LIBRARY)

# second lib, which will depend on and include the first one
#
include $(CLEAR_VARS)

LOCAL_MODULE    := libtwolib-second
LOCAL_SRC_FILES := second.c

LOCAL_STATIC_LIBRARIES := libtwolib-first

include $(BUILD_SHARED_LIBRARY)

We get this error: 我们得到这个错误:

could not read symbols: File in wrong format

Is it because the .a file is compiled with x86 and we are building for arm? 是因为.a文件是使用x86编译的,并且我们正在为arm进行构建?

The .a file is a legacy and most likely can't be recompiled from source. .a文件是旧文件,很可能无法从源文件重新编译。 If this is the issue, is there any other solution? 如果这是问题所在,还有其他解决方法吗?

Thanks. 谢谢。

You need to obtain the source for the third-party lib and cross-compile it to native Android's NDK such that its binary compatible. 您需要获取第三方库的源代码,并将其交叉编译为本地Android的NDK,以使其二进制兼容。

Simply dropping an x86 static lib into Android's NDK build will just not work. 简单地将x86静态库放到Android的NDK构建中将无法正常工作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM