3

I use Android NDK r8 to generate multiple static libraries with include $(BUILD_STATIC_LIBRARY) and I successfully get : lib1.a, lib2.a, lib3.a, etc.

Now I would like to merge these static libraries into single one.

I try do it with ar.exe from Android NDK :

android-ndk-r8\toolchains\arm-linux-androideabi-4.4.3\prebuilt\windows\arm-linux-androideabi\bin\ar.exe r libALL.a lib1.a lib2.a lib3.a

But when I use libAll.a into Android NDK makefile, it fails saying there is no index.

How can I add this index ?

Other question :

When I display contents of archive libAll.a, I see lib1.a, lib2.a, lib3.a instead of .o symbols from these libraries.

How can I change that (= extract .o from static libraries to merge it in libAll.a) ?

Thanks

TheFrancisOne
  • 2,667
  • 9
  • 38
  • 58

1 Answers1

1

ar is simply an archiving tool like zip. It takes the given input files and produces an .aarchive. If you want to include all .ofiles in a single archive, you have to specify each individual file. I don't know how to do this on WIndows, but on Linux you can use somthing like ar rs $(find . -name *.o).

Dan
  • 1,539
  • 12
  • 23
  • OK, thanks for answer. Do you know which tool I have to use to merge .a in single one ? – TheFrancisOne Jan 30 '13 at 09:53
  • 1
    You could try `ar x` to extract all object files and `ar rs` them again. However, I do not know whther this might screw some paths up. Also see http://stackoverflow.com/questions/3821916/how-to-merge-two-ar-static-libraries-into-one – Dan Jan 30 '13 at 09:55