1

尝试使用 Android 的 ADT Eclipse 工具链构建静态 NDK 库。但是,每当我使用 BUILD_STATIC_LIBRARY 构建时,都不会产生输出:我收到消息

make: Nothing to be done for `all'."

有什么建议吗?

LOCAL_PATH          := $(call my-dir)
STL_PATH            := "C:/Android/ndk/sources/cxx-stl/gnu-libstdc++/4.6/include"
PLATFORM_INCLUDE    := "C:/Android/ndk/sources/cxx-stl/gnu-libstdc++/4.6/libs/armeabi/include"
APP_STL             := gnustl_static

include $(CLEAR_VARS)

LOCAL_MODULE        := libCore
LOCAL_CPPFLAGS      += -std=c++11 -fexceptions -D_OS_ANDROID
LOCAL_LDLIBS        := -lGLESv2 -lEGL -lstdc++

LOCAL_C_INCLUDES    += $(LOCAL_PATH)/Headers
...

LOCAL_SRC_FILES     += Source/Engine/Game.cpp
...

include $(BUILD_STATIC_LIBRARY)
4

1 回答 1

2

这是来自 Android NDK 的两个库示例项目的 Android.mk 文件的内容。

LOCAL_PATH:= $(call my-dir)

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

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

include $(BUILD_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)

您可以尝试将静态库构建为另一个共享库的一部分,如示例中所示。

我刚刚在两个库示例项目上做了一个 ndk-build,我可以在obj\local\armeabi目录中看到 .a 文件和 .so 文件。

编辑:默认情况下,ndk-build 只会构建共享库和可执行文件,以及它们所依赖的模块。要强制构建,请在 APP_MODULES 中指定 libCore,如下所示。

APP_MODULES := libCore

或在命令行中

ndk-build APP_MODULES=libCore
于 2013-04-07T09:44:55.867 回答