Managment/Filenames of shared libraries
I'm currently dealing with shared libraries and there is one thing I do not really understand. I'll start of with a quote from Wikipedia:
Unix and Unix-like platforms more commonly use the term shared library or shared object; consequently, the .so filename extension occurs most commonly to identify shared library files in such environments — often followed by another dot and a version number (for example libc.so.6).
Doesn't sound so confusing, huh? Well it actually is. I just took a look at my /usr/lib directory... lots of .so files. But what I do not understand is the following: Sometimes I do have more than one file for the library (e.g. libz.so - libz.so.1 - libz.so.1.2.5) - ok different version numbers, so no problem... Well it would be no problem, but in every case of multiple libraries, all but one files are just symbolic links which point to the one real file. So my simple question: Why? Why are there severall files, almost the same filename, and then the just link to another file. And this is nothing that happens just once or tw开发者_高级运维ice...
Thanks
The reason this is done is so a program can depend on as specific a version of a library as it wants.
For example, a program may say "I need libs". The current default version of libz.so would point at libz.so.1.2.5.
Another program may say "I need version 1 of libz". The current default version of libz.so.1 points at libz.so.1.2.5.
libz.so.1.2.5 mostly exists so you know exactly what version you have installed. You can have multiple versions, and switch the symlinks around as necessary, but this is generally not done.
精彩评论