Section 3.4. Shared Libraries


3.4. Shared Libraries

Most if not all the applications we have ported use shared libraries. However, different operating systems have differences in creating and naming these shared libraries. In Linux, shared libraries may end with different file extensions. Shared libraries may end with .so or so.1.0 extensions. Shared libraries that end in .so with the extra dot followed by a number and a dot and another number are versioned libraries. The first number stands for the major number; the second number represents the minor number. Sometimes the extension comes with another dot and a number called the release number. The last dot and the release number are optional. Here is the format of the library filename:

lib<name>.so.<major>.<minor>.<release> 


The major, minor, and release numbers signify different changes that are made to the library. Here are some guidelines for incrementing the major, minor, and release numbers:

  • The major number is incremented when there is an incompatible change to the interface of the shared library. This major change implies that applications depending on the earlier major version of the library need to be changed to work with the new major version.

  • The minor number is incremented when a shared library preserves interfaces but adds new ones.

  • The release number is incremented when there is a compatible change that does not involve adding any new interfaces. This usually means that a change is made to the implementation to improve performance or scalability.

To create shared libraries in Linux, use the shared option in the compile arguments; this tells GNU ld to create a shared library rather than an application. Here is an example:

$ gcc o libfoo.so shared fpic foo.c 





UNIX to Linux Porting. A Comprehensive Reference
UNIX to Linux Porting: A Comprehensive Reference
ISBN: 0131871099
EAN: 2147483647
Year: 2004
Pages: 175

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net