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
Even better you perform partial linking on each library and them make an archive of the two resulting object files. That way it operates like shared libraries would
You do partial linking with
gcc -r --nostdlib
so either instead of making the intermediate archive or after reextracting it, run
gcc -r --nostdlib $CFLAGS $OBJECTS_A -o $LIBNAME_A.o
gcc -r --nostdlib $CFLAGS $OBJECTS_B -o $LIBNAME_B.o
then
ar -cr $LIBNAME_JOINED.a $LIBNAME_A.o $LIBNAME_B.o