gpt4 book ai didi

android-ndk - NDK : How to include Prebuilt Shared Library Regardless of Architecture

转载 作者:行者123 更新时间:2023-12-03 14:38:03 27 4
gpt4 key购买 nike

我正在移植 Box2D 以了解更多关于 android 移植的信息。
我可以编译项目并看到以下内容....

ls libs/

armeabi armeabi-v7a


现在我想做类似 this 的事情但我不知道如何让它足够聪明来选择拱门(比如我想添加 x86)。如何在不硬编码 .so 路径的情况下包含 .so 到规范架构?

最佳答案

只需按照 NDK 文档(APPLICATION-MK.html 和 PREBUILTS.html)中的描述,在 android.mk 和 Application.mk 中定义您想要支持的架构:

V. ABI Selection of prebuilt binaries:

As said previously, it is crucial to provide a prebuilt shared library that is compatible with the targeted ABI during the build. To do that, check for the value of TARGET_ARCH_ABI, its value will be:

armeabi => when targeting ARMv5TE or higher CPUs armeabi-v7a => when targeting ARMv7 or higher CPUs x86 => when targeting x86 CPUs mips => when targeting MIPS CPUs

Note that armeabi-v7a systems can run armeabi binaries just fine.

Here's an example where we provide two versions of a prebuilt library and select which one to copy based on the target ABI:

include $(CLEAR_VARS)
LOCAL_MODULE := foo-prebuilt
LOCAL_SRC_FILES := $(TARGET_ARCH_ABI)/libfoo.so
LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/include
include $(PREBUILT_SHARED_LIBRARY)

Here. we assume that the prebuilt libraries to copy are under the following directory hierarchy:

Android.mk            --> the file above
armeabi/libfoo.so --> the armeabi prebuilt shared library
armeabi-v7a/libfoo.so --> the armeabi-v7a prebuilt shared library
include/foo.h --> the exported header file

NOTE: Remember that you don't need to provide an armeabi-v7a prebuilt library, since an armeabi one can easily run on the corresponding devices.

关于android-ndk - NDK : How to include Prebuilt Shared Library Regardless of Architecture,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17172153/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com