【问题标题】:building a prebuilt static library with ndk-build all使用 ndk-build all 构建预构建的静态库
【发布时间】:2013-07-21 19:48:10
【问题描述】:

我对构建静态库的 ndk-build 脚本有疑问。

问题是这个脚本被我们应用程序更大的构建脚本所包含,它被ndk-build all调用

静态库的构建脚本如下所示:

# LoadBalancing-cpp

LOCAL_PATH := $(call my-dir)

all_static_libraries = common-cpp-static-prebuilt \
                       photon-cpp-static-prebuilt

lib_suffix := ${APP_OPTIM}_android_${APP_ABI}

lib_loadbalancing_cpp_static_name := loadbalancing-cpp-prebuilt-static_${lib_suffix}

include $(CLEAR_VARS)
LOCAL_MODULE            := loadbalancing-cpp-static-prebuilt
LOCAL_SRC_FILES         := lib$(lib_loadbalancing_cpp_static_name).a
LOCAL_STATIC_LIBRARIES  := $(all_static_libraries)
include $(PREBUILT_STATIC_LIBRARY)

$(call import-module,common-cpp-prebuilt)
$(call import-module,photon-cpp-prebuilt)

问题是,构建静态库需要 LOCAL_SRC_FILES 指向单个值(库的路径),但是在这种情况下使用 ndk-build all 调用时,它将包含多个值(因为 lib_suffix 将指向所有可用的架构)。

有没有办法使用 ndk-build all 来构建这个文件?

【问题讨论】:

    标签: android build android-ndk makefile


    【解决方案1】:

    您可以使用由 ndk-build 管理的 TARGET_ARCH 变量:

    lib_suffix := $(APP_OPTIM)_android_$(TARGET_ARCH)
    

    ...等等。

    本质上,ndk-build 会多次“调用”您的 Android.mk 文件,每次都以不同的方式设置 TARGET_ARCH 变量。

    【讨论】:

    • 我使用了 TARGET_ARCH_ABI 而不是 TARGET_ARCH,它有效,但根据您的回答,它可能不是正确的选择。
    • 也许 TARGET_ARCH_ABI 更适合您的目的
    猜你喜欢
    • 2023-03-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-03-06
    • 2016-08-15
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多