1

I have an Android project, featuring some native code, which use a static library for some Poco-library functions. I have currently linked in the arm7 build of the static library in the make files below. Now if i want to distribute this app on google play, for portatbility i need to include other architectures in the apk to. How do i include for example the static libPocofoundation.a for arm6 and the static libPocoFoundation.a for arm7 to the shared library in the apk?

include $(CLEAR_VARS)
LOCAL_ARM_MODE := arm
LOCAL_MODULE := PocoFoundation
LOCAL_SRC_FILES := Poco/libPocoFoundation.a   #<- How do i set this conditional-
#                                                 or add multiple architectures?
LOCAL_EXPORT_C_INCLUDES := /Users/poco-1.5.1-all/Foundation/include
LOCAL_EXPORT_CFLAGS := -DFOO=1 -fpermissive
LOCAL_EXPORT_LDLIBS := -llog
include $(PREBUILT_STATIC_LIBRARY)

Android.mk

LOCAL_PATH := $(call my-dir)
ROOT_PATH := $(LOCAL_PATH)
include $(call all-subdir-makefiles)
include $(CLEAR_VARS)
LOCAL_PATH = $(ROOT_PATH)

include $(CLEAR_VARS)
#LOCAL_MODULE_TAGS    := eng
LOCAL_ARM_MODE       := arm
LOCAL_MODULE    := JsonPoco # Your own library.
LOCAL_SRC_FILES := JsonPoco.cpp \


 # Your own library source.
LOCAL_WHOLE_STATIC_LIBRARIES := PocoFoundation \
PocoJSON
LOCAL_LDLIBS     := -llog
LOCAL_CFLAGS     := -DPOCO_ANDROID -DPOCO_NO_FPENVIRONMENT -DPOCO_NO_WSTRING -DPOCO_NO_SHAREDMEMORY
LOCAL_CPPFLAGS   := -frtti -fexceptions 
include $(BUILD_SHARED_LIBRARY)

2 Answers 2

4

If I understand well, you want to include different builds of this static library, located in different paths.

As Rajitha said, the first step to support multiple platforms is to mention them in the Application.mk. For example, to support ARMv5/6 and ARMv7:

APP_ABI := armeabi armeabi-v7a

Then in your Android.mk, you'll want to change the path you use for the static library depending on the platform currently being built:

ifeq ($(TARGET_ARCH_ABI),armeabi-v7a)
    LOCAL_SRC_FILES := /path/to/armv-7/libPocofoundation.a
else
    LOCAL_SRC_FILES := /path/to/armv-6/libPocofoundation.a
endif

You can do this if/else condition on more architectures if you want to support x86 for example.

Sign up to request clarification or add additional context in comments.

3 Comments

It seems that eclipse marks all of my imports as armeabi: (is this a problem?) Clean: PocoFoundationArm [armeabi] Clean: PocoFoundationArm7 [armeabi] Clean: PocoJSONArm [armeabi] Clean: PocoJSONArm7 [armeabi]
I guess there's something wrong indeed: I checked the output of my own ndk-build clean and each library is cleaned only under its own architecture. Maybe it's a known issue in Eclipse? (I personnaly use the ndk-build command line tool directly, not Eclipse).
It seems eclipse ignores my armeabi-libraries but use only arm7: /Applications/adt-bundle-mac-x86_64/android-ndk-r8d/build/core/build-binary.mk:419: warning: overriding commands for target `obj/local/armeabi/libPocoFoundation.a' Prebuilt : libPocoFoundation.a <= jni/Poco/arm7/
0

Modify the APP_ABI in your Application.mk to

APP_ABI := all

2 Comments

Paths for the other .a libraries is added how?
probably excessive for this case, if they don't need x86 or other future supported arch's

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.