开发者

How to do versioning of shared library?

开发者 https://www.devze.com 2023-04-07 20:30 出处:网络
Windows provides the resource file for version information for an application and DLL. The resource file includes information like version, copyright and manufacturer.

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开发者_C百科 like to add version information.

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


The short version is that you do this via the soname of the library. Read chapter 3 at http://tldp.org/HOWTO/Program-Library-HOWTO/shared-libraries.html as well as chapter 3.3 ABI Versioning at http://www.akkadia.org/drepper/dsohowto.pdf


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.


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)

0

精彩评论

暂无评论...
验证码 换一张
取 消