Android NDK : Compiling different libraries for different architectures

slamnjam

I have a small c++ library that must be compiled for both armeabi and armeabi7a. I also have a very large c++ library that only needs to be compiled for armeabi. Right now they are being compiled (using NDK) for both architectures, but this is making my .apk very big. Is it possible to target the big library to be compiled only for armeabi? How would I do this?

My folder structure is something like this:

/jni/biglib/
/jni/smalllib/
/jni/Application.mk
/jni/Android.mk

My /jni/Application.mk file contains:

APP_ABI := armeabi-v7a armeabi
APP_OPTIM := release

My root /jni/Android.mk file combines the Android.mk files for each library:

LOCAL_PATH := $(call my-dir)
LOCAL_C_INCLUDE := $(LOCAL_PATH)/include

include $(addprefix $(LOCAL_PATH)/, $(addsuffix /Android.mk, \
    biglib \
    smalllib \
))
Matěj Hrazdíra

It is definitely possible. There are some code snippets to get you going (without exact content of Android.mk for biglib and smallib I can't help you more).

1) Change order of APP_ABI to APP_ABI := armeabi armeabi-v7a in Application.mk.

2) Modify your root Android.mk:

LOCAL_PATH := $(call my-dir)
LOCAL_C_INCLUDE := $(LOCAL_PATH)/include

# biglib is not built for armeabi-v7a
ifneq "$(TARGET_ARCH_ABI)" "armeabi-v7a"
  include $(LOCAL_PATH)/biglib/Android.mk
endif

# ----- cut here -----
# Place this snippet to every module which needs biglib, or where convenient.
# Now you will link against armeabi version of biglib.
ifeq "$(TARGET_ARCH_ABI)" "armeabi-v7a"
  LOCAL_LDFLAGS += $(LOCAL_PATH)/../obj/local/armeabi/libbigLib.so
endif
# ----- cut here -----

include $(LOCAL_PATH)/smalllib/Android.mk

And thats all - your apk file now doesn't contain libbiglib.so for armeabi-v7a

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Android NDK: Use same library across different ABI architectures

From Dev

integration of libraries in the project under different architectures

From Dev

Android mobile chip architectures different in different countries?

From Dev

different kernels for different architectures

From Dev

Android NDK and CPU architectures

From Dev

Compiling android-ndk module with different STL than defined in Application.mk

From Dev

Compiling shared and static libraries into a shared library using the Android NDK

From Dev

NDK & Android Studio, compiling it crashes because of shared libraries

From Dev

Programming on different ARM architectures

From Dev

How to make same compiled C code work on different architectures without compiling it again?

From Dev

android ndk communicate different c++ project

From Dev

Prebuilding different kind of static library in Android NDK

From Dev

File operations in C on different architectures

From Dev

Casting pointer types on different architectures

From Dev

Generate APK for different architectures - FFmpegMediaMetadataRetriever

From Dev

File operations in C on different architectures

From Dev

Casting pointer types on different architectures

From Dev

Behavior of getCString and withCString on different architectures

From Java

How to combine android static libraries with different ABIs?

From Dev

Different ndk code for flavor

From Dev

Different ndk code for flavor

From Dev

Android NDK and Gradle: Different Android.mk per build type

From Dev

Different results and performances with different libraries

From Dev

Different type libraries for different versions

From Dev

Why is ndk-build producing two different libraries, one very large and one smaller?

From Dev

Compiling to a different python version

From Dev

Compiling to a different python version

From Dev

How to Build Visual Studio Projects for Different Architectures

From Dev

Are binaries portable across different CPU architectures?

Related Related

  1. 1

    Android NDK: Use same library across different ABI architectures

  2. 2

    integration of libraries in the project under different architectures

  3. 3

    Android mobile chip architectures different in different countries?

  4. 4

    different kernels for different architectures

  5. 5

    Android NDK and CPU architectures

  6. 6

    Compiling android-ndk module with different STL than defined in Application.mk

  7. 7

    Compiling shared and static libraries into a shared library using the Android NDK

  8. 8

    NDK & Android Studio, compiling it crashes because of shared libraries

  9. 9

    Programming on different ARM architectures

  10. 10

    How to make same compiled C code work on different architectures without compiling it again?

  11. 11

    android ndk communicate different c++ project

  12. 12

    Prebuilding different kind of static library in Android NDK

  13. 13

    File operations in C on different architectures

  14. 14

    Casting pointer types on different architectures

  15. 15

    Generate APK for different architectures - FFmpegMediaMetadataRetriever

  16. 16

    File operations in C on different architectures

  17. 17

    Casting pointer types on different architectures

  18. 18

    Behavior of getCString and withCString on different architectures

  19. 19

    How to combine android static libraries with different ABIs?

  20. 20

    Different ndk code for flavor

  21. 21

    Different ndk code for flavor

  22. 22

    Android NDK and Gradle: Different Android.mk per build type

  23. 23

    Different results and performances with different libraries

  24. 24

    Different type libraries for different versions

  25. 25

    Why is ndk-build producing two different libraries, one very large and one smaller?

  26. 26

    Compiling to a different python version

  27. 27

    Compiling to a different python version

  28. 28

    How to Build Visual Studio Projects for Different Architectures

  29. 29

    Are binaries portable across different CPU architectures?

HotTag

Archive