Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can someone explain about Linux library naming?

Tags:

When I create a library on Linux, I use this method:

  1. Build: libhelloworld.so.1.0.0
  2. Link: libhelloworld.so.1.0.0 libhelloworld.so
  3. Link: libhelloworld.so.1.0.0 libhelloworld.so.1

The versioning is so that if you change the public facing methods, you can build to libhelloworld.so.2.0.0 for example (and leave 1.0.0 where it is), so that applications using the old library won't break.

However, what's the point in naming it 1.0.0 - why not just stick with libhelloworld.so and libhelloworld.so.1?

Also, is it best practice to name your library using 1.0.0 for example, or just 1?

g++ ... -Wl,-soname,libhelloworld.1 

Or:

g++ ... -Wl,-soname,libhelloworld.1.0.0 
like image 794
Nick Bolton Avatar asked Mar 19 '09 17:03

Nick Bolton


1 Answers

The way you're supposed to form the x.y.z version is like this:

  1. The first number (x) is the interface version of the library. Whenever you change the public interface, this number goes up.
  2. The second number (y) is the revision number of the current interface. Whenever you make an internal change without changing the public interface, this number goes up.
  3. The third number (z) is not a build number, it is the backwards-compatability count. This tells you how many previous interfaces are supported. So for example if interface version 4 is strictly a superset of interfaces 3 and 2, but totally incompatible with 1, then z=2 (4-2 = 2, the lowest interface number supported)

So the x and z numbers are very important for the system to determine if a given app can use a given library, given what the app was compiled against. The y number is mainly for tracking bug fixes.

like image 76
Tyler McHenry Avatar answered Sep 19 '22 08:09

Tyler McHenry