简体   繁体   English

如何将多个库存档(.a)打包到一个存档文件中?

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

How can I turn multiple archive files into one big archive file on Linux (using binutils ar and / or GCC). 如何在Linux上将多个归档文件转换为一个大型归档文件(使用binutils ar和/或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). 我尝试过像ar rcs libbig.a libsmall1.a libsmall2.a这样的东西,它不起作用(生成的libbig.a为空)。

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 (eg nm) were unwilling to look deeper into these files. 像你一样运行ar rcs会产生一个包含两个.a文件的存档,但是工具(例如nm)不愿意深入研究这些文件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM