我试过了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),情况也是如此,然后执行gcc -shared -Wl,soname,c.so -o c.so a.a b.a谢谢 解决方案 在所有 UNIXen 上实际上不可能将多个共享库合并为一个,除了 AIX:链接器将 .so 视为最终"产品.但是将档案合并到 .so 应该不是问题:gcc -shared -o c.so -Wl,--whole-archive a.a b.a -Wl,--no-whole-archiveSay 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)?I triedgcc -shared -Wl,soname,c.so -o c.so a.so b.sobut it doesn't work.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 dogcc -shared -Wl,soname,c.so -o c.so a.a b.aThanks 解决方案 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 共享库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!
08-06 11:33