Artem Artem - 6 months ago 102
Android Question

Android, NDK, building static library

Is it possible to build static (.a) library using ndk-build from several other static (.a) libraries.

For example, I have several libraries: lib1.a, lib2.a, lib3.a and I need to build libmegalib.a lib

Using LOCAL_WHOLE_STATIC_LIBRARIES and include $(BUILD_STATIC_LIBRARY) dosn't help.
It creates libmegalib.a lib, but it contains "!<arch>" content only (8 bytes).

But I need libmegalib.a contain all my libs: lib1.a, lib2.a, lib3.a

Answer

You should be able to use ar (arm-linux-androideabi-ar from the appropriate NDK toolchain) to achieve this:

arm-linux-androideabi-ar -xv lib1.a 
arm-linux-androideabi-ar -xv lib2.a 
arm-linux-androideabi-ar -xv lib3.a 
arm-linux-androideabi-ar -rc libmegalib.a *.o