This is a trick used for versions of shared object files. This is a way to avoid the terrible DLL hell that arose because of the lazy link.
The advantage of lazy binding (or late binding) is that the components of your executable can be changed without actually binding those executables. This allows you to fix errors in third-party components without having to send a new executable file, among other things.
The disadvantage is the same as the advantage. Your executable may find that the assumptions made regarding the base libraries have been changed, and this can cause all kinds of problems.
A version of shared objects is one way to avoid this. Another would not be to separate objects at all, but it also has pros and cons, which I will not enter here.
As an example, suppose you have version 1 of xyz.so You have a file and a symbolic link to this file:
pax> ls -al xyz* -rw-r--r-- 1 pax paxgroup 12345 Nov 18 2009 xyz.so.1 lrwxrwxrwx 1 pax paxgroup 0 Nov 18 2009 xyz.so -> xyz.so.1
Now, when you create the exe1 by linking it to xyz.so , it will follow a symbolic link so that it xyz.so.1 in the executable as the thing that it should load at runtime.
Thus, when updating a shared library:
pax> ls -al xyz* -rw-r--r-- 1 pax paxgroup 12345 Nov 18 2009 xyz.so.1 -rw-r--r-- 1 pax paxgroup 67890 Nov 18 2009 xyz.so.2 lrwxrwxrwx 1 pax paxgroup 0 Nov 18 2009 xyz.so -> xyz.so.2
your source executable exe1 will download version 1 of the shared object.
However, any executable files that you are creating now (for example, exe2 ) will be associated with version 2 of the shared object.
The actual implementation details may vary slightly (I'm basing my answer on earlier UNIX, and Linux seems to make version control a little more reasonable than just following the symlinks). IBM developerWorks has a good article on how to do this here .
When you create a shared object, you give it both a real name and a soname . They are used to set a common object (which creates both an object and a link to it).
Thus, you may encounter a situation:
pax> ls -al xyz* -rw-r--r-- 1 pax paxgroup 12345 Nov 18 2009 xyz.so.1.5 lrwxrwxrwx 1 pax paxgroup 0 Nov 18 2009 xyz.so.1 -> xyz.so.1.5 lrwxrwxrwx 1 pax paxgroup 0 Nov 18 2009 xyz.so -> xyz.so.1
with xyz.so.1.5 having soname of xyz.so.1 .
When the linker references in xyz.so , it follows the links until xyz.so.1.5 and uses soname xyz.so.1 to store in the executable. Then, when you run the executable, it tries to download xyz.so.1 , which will point to a specific xyz.so.1.N (not necessarily version 1.5).
So, you can install xyz.so.1.6 and update the xyz.so.1 link to point to it, and instead the already linked executables will be used.
One of the advantages of this multi-level method is that you can have several potentially incompatible libraries with the same name ( xyz.so.1.* , xyz.so.2.* ), But in each major version you can freely Update them as they are intended for compatibility.
When you link new executables:
- Those who contact
xyz.so will receive the latest version of the latest version. - Others associated with
xyz.so.1 will receive the latest small version of a specific major version. - Other links related to
xyz.so.1.2 will receive a specific minor version of a specific major version.