Search code examples
linuxstatic-librariesunix-ar

How to merge two "ar" static libraries into one?


I have 2 static Linux libraries, created by ar cr, libabc.a and libxyz.a.
I want to merge them into one static library libaz.a.
How can I do this.

I want to create a merged static library, not to give both libraries to final link of applications.


Solution

  • You can extract the object from both the .a files and create your .a file using the extracted .os:

    ar -x libabc.a
    ar -x libxyz.a
    ar -c libaz.a  *.o