问题
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