From an old email I sent to a colleague about this question:
Let's look at libxml as an example. First of all, shared
objects are stored in /usr/lib with a series of symlinks to represent
the version of the library availiable:
lrwxrwxrwx 1 root root 16 Apr 4 2002 libxml.so -> libxml.so.1.8.14
lrwxrwxrwx 1 root root 16 Apr 4 2002 libxml.so.1 -> libxml.so.1.8.14
-rwxr-xr-x 1 root root 498438 Aug 13 2001 libxml.so.1.8.14
If I'm the author of libxml and I come out with a new version, libxml
2.0.0 that breaks interface compatiblity with the previous version, I
can install it as libxml.so.2, and libxml.so.2.0.0. Note that it is
up to the application programmer to be responsible about what he links
to. If I'm really anal, I can link directly to libxml.so.1.8.14 and
any other version will result in my program not running. Or I can
link against libxml.so.1 and hope that the libxml developer doesn't
break symbol compatibility on me in the 1.X version. Or if you don't
care and are reckless, just link to libxml.so and get whatever version
there is. Sometimes, when enough people do this, the library author
has to get creative with later versions. Hence, libxml2:
lrwxrwxrwx 1 root root 17 Apr 4 2002 libxml2.so.2 -> libxml2.so.2.4.10
-rwxr-xr-x 1 root root 692727 Nov 13 2001 libxml2.so.2.4.10
Note that there's no libxml2.so in this one. Looks like the developer
got fed up with irresponsible application developers.