Can UNIX shared libraries be merged into a single library?

六眼飞鱼酱① 提交于 2019-12-24 09:18:14

问题


I am experimenting with my own BSD or Linux distribution. I want to organize the system files in a way that makes sense to an end user. I want them to have access to the system without all the file clutter that *nixes leave around.

Is there a way to merge several dynamic libraries into a single file without losing dynamic linking? I will have access to all of the source files.


回答1:


It might be system-dependent, but at least with ELF (the executable format used by Linux), this is not possible. With ELF, shared libraries are a bit like executables: they are a final product of the linking process and are not designed to be decomposed or relinked into a different arrangement.

If you have the source for all of the components that go into a bunch of shared libraries, I suppose you could link them all together into one giant shared library, but you would use object files (*.o) or archive libraries (*.a) as the input to produce such a library.

As alluded to in comments, there is unlikely to be a good reason to want to actually do this.



来源:https://stackoverflow.com/questions/14987258/can-unix-shared-libraries-be-merged-into-a-single-library

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!