How to pack multiple library archives (.a) into one archive file?

前端 未结 1 1776
萌比男神i
萌比男神i 2020-12-19 17:02

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.

1条回答
  •  萌比男神i
    2020-12-19 17:49

    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.

    0 讨论(0)
提交回复
热议问题