4

How can I turn multiple archive files into one big archive file on Linux (using binutils ar and / or GCC).

I tried doing things like ar rcs libbig.a libsmall1.a libsmall2.a and it doesn't work (the resulting libbig.a is empty).

Andrzej H
  • 434
  • 3
  • 9

1 Answers1

6

Just tried this on my machine and the problem seems to be that you need to extract the objects from the archives before adding them to the new archive:

ar x libsmall1.a
ar x libsmall2.a
ar rcs libbig.a *.o

Simply running ar rcs like you did produced an archive which contained two .a files, but tools (e.g. nm) were unwilling to look deeper into these files.

Flexo
  • 87,323
  • 22
  • 191
  • 272
  • That's what I was afraid that has to be done, but I thought there might be some clever way to do it with AR, hackish-voodoo or something ;-). – Andrzej H Feb 14 '11 at 23:57