Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to do versioning of shared library?

Windows provides the resource file for version information for an application and DLL. The resource file includes information like version, copyright and manufacturer.

We have a shared library and would like to add version information.

How can we do it on Linux with a shared library?

like image 539
CrazyC Avatar asked Sep 26 '11 09:09

CrazyC


2 Answers

Linux uses the following strategy - you (the system maintainer) provide symlinks from a 'specific' shared library file, like this:

lrwxrwxrwx 1 root root    16 2011-09-22 14:36 libieee1284.so -> libieee1284.so.3
lrwxrwxrwx 1 root root    20 2011-09-22 14:36 libieee1284.so.3 -> libieee1284.so.3.2.2
-rw-r--r-- 1 root root 46576 2011-07-27 13:08 libieee1284.so.3.2.2

This way, developers can link either against -lieee1284 (any version ABI), or libieee1284.so.3 or even to the specific release and patch version (3.2.2)

like image 194
qdot Avatar answered Sep 20 '22 15:09

qdot


The best way to handle this is using libtool, which does the versioning for you.

Essentially, version information is not (or not primarily, don't know from my head) encoded in the library itself, but rather in its filename. Version numbers are normally given in three-dot format, with the major number increasing for each break in downward ABI compatibility, the middle for breaks in upward ABI compatibility, and the minor for patches that did not change the ABI.

Like qdot noted, symlinks in the lib directory provide the essential versioning. There is a symlink without a version number (libfoo.so) for the currently installed development headers, a symlink with a major number for each installed major version (libfoo.so.1) and a real file with the full version number. Normally, programs are linked to use libfoo.so.1 at runtime so that multiple major versions may coexist.

like image 37
thiton Avatar answered Sep 19 '22 15:09

thiton