合并多个的.so共享库 [英] Merge multiple .so shared libraries

查看:463
本文介绍了合并多个的.so共享库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

说我有a.so和b.so.
我可生产c.so与由A和B导出的所有功能单一的共享库,当然解决所有内部的依赖关系(即由b.so和a.so周围的其他方法调用的所有函数)?

Say I have a.so and b.so. Can I produce c.so as a single shared library with all the functions exported by a and b, of course resolving all intra-dependencies (i.e. all functions of b.so called by a.so and the other way around)?

我试过

gcc -shared -Wl,soname,c.so -o c.so a.so b.so

,但它不工作

也是一样,如果我在存档和A.A b.a(这不应该修改a.o和B.O),并做a.o和B.O

Same goes if I archive a.o and b.o in a.a and b.a (which shouldn't modify a.o and b.o), and do

gcc -shared -Wl,soname,c.so -o c.so a.a b.a

感谢

推荐答案

合并多个共享库到一个确实是所有UNIXen几乎是不可能的,除非AIX:连接器认为。所以最终产品

Merging multiple shared libraries into one is indeed practically impossible on all UNIXen, except AIX: the linker considers the .so a "final" product.

但合并成归档。所以不应该是一个问题:

But merging archives into .so should not be a problem:

gcc -shared -o c.so -Wl,--whole-archive a.a b.a -Wl,--no-whole-archive

这篇关于合并多个的.so共享库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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