gpt4 book ai didi

Android NDK : How to get compiler architecture in Android. mk 动态

转载 作者:IT老高 更新时间:2023-10-28 21:37:26 26 4
gpt4 key购买 nike

我正在尝试配置 Android.mk 以交叉编译 native 代码以支持不同的芯片组,即 armeabi、mips 和 x86。我知道我可以通过以下方式配置 Application.mk 来编译不同芯片组的源代码:

APP_ABI := all

这将触发 Android-NDK 的构建脚本来编译所有芯片组的源代码。但是,我想动态地告诉 Android.mk 查找使用不同芯片组编译的不同静态库依赖项。

# Get the architecture info
ARCH := ????

include $(CLEAR_VARS)
LOCAL_MODULE:= mylib
LOCAL_SRC_FILES:= build/lib/libxxx_$(ARCH).a
LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)
include $(PREBUILT_STATIC_LIBRARY)

这可能吗?如果是这样,任何人都可以建议如何做到这一点?

Update: I tried something like this in Application.mk:

 APP_ABI := armeabi armeabi-v7a mips x64

with Android.mk:

# Get the architecture info
ARCH := $(APP_ABI)

include $(CLEAR_VARS)
LOCAL_MODULE:= mylib
LOCAL_SRC_FILES:= build/lib/libxxx_$(ARCH).a
LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)
include $(PREBUILT_STATIC_LIBRARY)

but it errors with the following:

 The LOCAL_SRC_FILES for a prebuilt static library should only contain one item

which makes sense. I want to pass APP_ABI := all in Application.mk and be able to dynamically reference it. Any ideas?

最佳答案

检查TARGET_ARCH_ABI:

ifeq($(TARGET_ARCH_ABI), armeabi-v7a)
# v7a-specific stuff
endif

关于Android NDK : How to get compiler architecture in Android. mk 动态,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12614417/

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