Naming conventions for shared libraries in Linux

Hello,

I'm wondering what is the naming conventions for *.so shared libraries in linux. For example, a library in /lib, say libcrypt-2.7.so has a symbolic link called libcrypt.so.1 pointing to it, yet libncursesw.so.5.6 has a symbolic link called libncursesw.so.5 pointing to it. What is the relationship between the numbers in the symbolic links and the actual targets?

They are version numbers, and are there for two reasons; so that you can safely and easily upgrade your libraries, and so you can have more than one version of them installed at the same time.

When there's two numbers there's a major and a minor version. libncursesw.so.5.6 has major version 5 and minor version 6; in theory any minor version of the same major version is compatible without recompiling, so programs that linked to libncursesw.so.5 wouldn't miss a beat if you upgraded to 5.7 for a bugfix. If you had an ancient program demanding version 4, you could safely install a 4.x library alongside the 5.x ones, and nothing but that program would use it.

Sometimes programmers don't think that far ahead though; they might link to a too specific version, breaking their program every time you upgrade a library, or link to libncursesw.so itself, causing crashes and/or strange runtime errors when the library's not what they expected.

Shared libraries have a special name called the "soname'' which consists of the prefix "lib'', the name of the library, ".so'', followed by a period and a major version number that is incremented whenever the library APIs change.

Shared libraries also has a "real name'', which is the name of the file containing the actual library code. The real name is the soname followed by a period and a minor number, optionally followed by another period and a release number. Generally a fully qualified soname is simply a symbolic link to the real name.

For more information, look at the Linux Standard Base specifications.