1, 如果简单用-l的方式,则so只会链接lib中需要的符号,如果需要将所有符号都塞到SO里面,可以用下面的方法:
http://stackoverflow.com/questions/7935421/linking-archives-a-into-shared-object-so
Use -Wl,--whole-archive for the linking to include the entire .a file Edit, you'll need to add -Wl,--no-whole-archive after you specify your library as well, so the whole thing will be -Wl,--whole-archive archive1.a archive2.a -Wl,--no-whole-archive
2,一个so链接到多个app
1)app运行时会自动加载需要的so文件
2)多个app可以共用so文件的代码段,但数据段是独立的
参考linker and loader
3)对于临界区代码需要增加进程间的互斥处理
4)so必须是自成系统,如果对某个app其他代码有依赖,就会在其他app找不到符号。
5)可以用不同的初始化&适配函数来定制so提供的功能。
本文介绍了如何将静态库(.a)完整地链接到动态库(.so)中,包括使用特定链接选项的方法以及注意事项。讨论了动态库在不同应用程序间共享的机制,强调了进程间同步的重要性,以及动态库应自包含以避免依赖问题。
2233

被折叠的 条评论
为什么被折叠?



