android-ndk将静态库添加到android.mk中

时间:2011-10-05 14:45:06

标签: android makefile java-native-interface android-ndk

我有一个框架中的三个静态库,我想在我的项目中使用它。这些库称为libtinySAK_armv7-a.a, libtinyNET_armv7-a.a and libtinyHTTP_armv7-a.a。我已将它们放在与Android.mkApplication.mk相同的文件夹中。

我的本​​机代码依赖于它们,所以我想将它们包含在我的共享库中。

从我在stackoverflow和google上读到的内容我相信android.mk看起来应该是这样的:

# TINYSAK
include $(CLEAR_VARS)

LOCAL_MODULE    := tinySAK
LOCAL_SRC_FILES := libtinySAK_armv7-a.a
LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/../../../doubango/tinySAK/src/

include $(PREBUILT_STATIC_LIBRARY)


# TINYNET
include $(CLEAR_VARS)

LOCAL_MODULE    := tinyNET
LOCAL_SRC_FILES := libtinyNET_armv7-a.a
LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/../../../doubango/tinyNET/src/

include $(PREBUILT_STATIC_LIBRARY)


# TINYHTTP
include $(CLEAR_VARS)

LOCAL_MODULE    := tinyHTTP
LOCAL_SRC_FILES := libtinyHTTP_armv7-a.a
LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/../../../doubango/tinyHTTP/include/

include $(PREBUILT_STATIC_LIBRARY)




LOCAL_PATH := $(call my-dir)

include $(CLEAR_VARS)

LOCAL_MODULE    := libtest

LOCAL_SRC_FILES := \
../../test/stack.cpp \
../../test/main.cpp 

LOCAL_C_INCLUDES := \
$(LOCAL_PATH)/../../test/include/ \
$(LOCAL_PATH)/../../../doubango/tinyHTTP/include/ \
$(LOCAL_PATH)/../../../doubango/tinySAK/src/ \
$(LOCAL_PATH)/../../../doubango/tinyNET/src/ 

LOCAL_STATIC_LIBRARIES := \
tinySAK \
tinyNET \
tinyHTTP

include $(BUILD_SHARED_LIBRARY)

我的Application.mk:

APP_STL := stlport_static
APP_ABI := armeabi-v7a

我在编译时遇到的错误(来自项目目录的“ndk-build”)是

jni/Android.mk:tinySAK: LOCAL_SRC_FILES  points to a missing file 

我想其他2个库也会失败。为什么不能找到它们? 除此之外,我在makefile中还有其他错误吗?

由于

2 个答案:

答案 0 :(得分:3)

没关系,我解决了。

我只在make文件的开头声明了“LOCAL_PATH”。否则它会在ndk文件夹中查找lib。

答案 1 :(得分:2)

尝试使用LOCAL_LDLIBS代替LOCAL_SRC_FILES