I'm reading http://www.tldp.org/HOWTO/Program-Library-HOWTO/shared-libraries.html and I had some questions.
What is difference between version, minor and release number? What is meant by the part "version number is incremented whenever the interface changes"?
The soname has the prefix
lib
, the name of the library, the phrase.so
, followed by a period and a version number that is incremented whenever the interface changes.The real name adds to the soname a period, a minor number, another period, and the release number.
Each time you release the library, it should arguably have a different version number. However, some releases only make changes to the internal workings of the library without affecting users at all other than by fixing bugs. Other releases may also add new functions to the library, but the interface details of all the existing functions are the same as before, so software written to use an older version of the library will continue to work with the new version. Other changes may break backwards compatibility; a function interface changes, a structure changes size, or a function is dropped (or a global variable — perish the thought — changes, etc).
The 'bug fix only' versions might not bother with renumbering the library, but if you previously had
liberror.so.1.0.2
, the new version might beliberror.so.1.0.3
, a change in the release number.The 'additional features' versions should be given a new minor number, so the new version after
liberror.so.1.0.2
might beliberror.so.1.1.0
.If you break compatibility, then you use a new version number, so the new version after
liberror.so.1.0.2
might beliberror.so.2.0.0
.Code built to use
liberror.so.1.0.2
can and will use eitherliberror.so.1.0.3
orliberror-1.1.0
without problem, but will not attempt to useliberror.so.2.0.0
or later versions.Good question. This is my understanding, but I might have some details wrong (in which case, someone will probably point out the error of my ways). The theory above is nice an easy; this is a little less easy.
You may have noticed that there are 'development' packages for libraries as well as the 'standard' versions of the libraries. The difference between them is part of the explanation.
If you're an ordinary end user who is not writing programs using a library but simply running programs that someone else has written, then you typically end up with one file and one symlink in the installation directory. Continuing with the hypothetical
liberror.so.1.0.2
example (installed in/usr/local/lib
), you would find in the base release:If you installed the development version, you'd probably find some header files in
/usr/local/include
, some man pages (perhaps in/usr/local/man
, perhaps in/usr/share
instead), and an extra symlink:When the program using it is compiled, you might specify:
This will link with the name
liberror.so
, but reading the metadata from theliberror.so.1.0.2
file, it would know that the version to use isliberror.so.1.0.2
or later (but notliberror.so.2.0.0
or later).Now let's suppose you upgrade the installation to
liberror.so.2.0.0
. You now have files:Old code built to use
liberror.so.1
still runs using that library. New code built to useliberror.so.2
also runs using the new library. And at link time, new programs pick upliberror.so.2.0.0
via the symlinkliberror.so
.You can control it so that the default on your system is still
liberror.so.1
by adjusting theliberror.so
symlink to point toliberror.so.1.0.2
. The only tricky part is making sure that the correct versions of the headers are available for compilation. It is a bad idea to build with the headers forliberror.so.2
and link withliberror.so.1
because the one thing you know for sure is that the interfaces are different!Some raw data from a Red Hat Enterprise Linux 5 (RHEL5) x86_64 machine.
You can see the
libc.so.6
is a symlink tolibc-2.5.so
. You can also a number of versions oflibcrypto
, not including the link-time librarylibcrypto.so
. You can also see libraries with only two parts to the version number, etc. The represented libraries arelibc
,libcap
,libcidn
,libcom_err
,libcrypt
andlibcrypto
.