如何将多个库档案(.a)打包到一个档案文件中? [英] How to pack multiple library archives (.a) into one archive file?

查看:189
本文介绍了如何将多个库档案(.a)打包到一个档案文件中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在Linux上使用binutils ar和/或GCC将多个存档文件转换为一个大存档文件.

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

我尝试做类似ar rcs libbig.a libsmall1.a libsmall2.a的操作,但它不起作用(结果libbig.a为空).

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

推荐答案

仅在我的机器上尝试过,问题似乎是您需要从归档中提取对象,然后再将它们添加到新的归档中:

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

像您一样简单地运行ar rcs会生成一个包含两个.a文件的存档,但是工具(例如nm)不愿意深入研究这些文件.

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.

这篇关于如何将多个库档案(.a)打包到一个档案文件中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆