How to build multiple projects in the correct order of dependency with Android NDK?

I have a series of existing libraries that I need to reuse in an Android app. The layout is similar to:

\ Libraries \ libOne
\ Libraries \ libTwo [Static Library]
\ Libraries \ libThree
\ Applications \ MyApplication \ [Application]

libTwodepends on libOne, but libThreedepends on libTwo. How can I get the build system to assemble all the libraries in the correct order? I am trying to use Eclipse, but if necessary I can use the command line.

All of these libraries will eventually be referenced by a Java application (and use the JNI to interact with them). Any tips on how I'm setting up Android.mk/Application.mk files?

I tried using BUILD_STATIC_LIBRARYfor libTwo, but actually it does not output any files! I was expecting a file libTwo.a, but nothing compiles or builds.

Am I writing one Android.mk in an application? Or Android.mk for each project?

+5
source share
2 answers

OK, now I see your editing, and this allows you to answer a specific question.

Android.mk , Android NDK . . , , Cmake, " toolchain" "" make MS Visual Studio . . , .

${project_root}/libs/armeabi/ ( ARM v6 , x86, MIPS, arm v7a), APK- , ( ) /data/data/${package_name}/lib , , System.loadLibrary(short_name) Java. so -, ( ).

, Android.mk ${project_root}/jni. ndk-build , Android.mk. , (, ), , , Android.mk. , ndk-build - , gnu make, include Android.mk , make .

, , , Applications/MyApplication/ [Application]/jni/Android.mk :

include ../../Libraries/libOne/Android.mk
include ../../Libraries/libTwo/Android.mk
include ../../Libraries/libThree/Android.mk

, libOne libTwo, libOne Libraries/libOne/Android.mk

LOCAL_PATH = $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE    := libOne
LOCAL_SRC_FILES := first.c
include $(BUILD_STATIC_LIBRARY)

Libraries/libThree/Android.mk

LOCAL_PATH = $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE    := libThree
LOCAL_SRC_FILES := third.c
LOCAL_C_INCLUDES := $(LOCAL_PATH)/../libOne $(LOCAL_PATH)/../libTwo
LOCAL_STATIC_LIBRARIES := libOne libTwo
include $(BUILD_SHARED_LIBRARY)

ndk-build Applications/MyApplication/ [Application] - , Eclipse ADT.

update Android.mk jni:

LOCAL_PATH = ../../Libraries/libOne
include $(CLEAR_VARS)
LOCAL_MODULE    := libOne
LOCAL_SRC_FILES := first.c
include $(BUILD_STATIC_LIBRARY)

LOCAL_PATH = ../../Libraries/libThree
include $(CLEAR_VARS)
LOCAL_MODULE    := libThree
LOCAL_SRC_FILES := third.c
LOCAL_C_INCLUDES := $(LOCAL_PATH)/../libOne $(LOCAL_PATH)/../libTwo
LOCAL_STATIC_LIBRARIES := libOne libTwo
include $(BUILD_SHARED_LIBRARY)
+3

, . , libOne libTwo libThree .

0

All Articles