Why do I need a .so.1 file on Linux?

On Linux for shared libraries, I usually see the .so, .so.1 and .so.1.0 files of the same library. For example, a library test should be presented libtest.so libtest.so.1 libtest.so.1.0. As I understand it, .so.1.0 contains real data; .so is associated with .so.1.0 and is used when binding. But I do not understand the purpose of the .so.1 file. Can someone clarify the use of the .so.1 file? Thank you

+7
c linux dynamic-linking
source share
2 answers

Say we are talking about libtest . If you look around, you'll see libtest.so , which is a link to libtest.so.1 , which in turn refers to libtest.so.1.5 .

In this case, the executable using libtest will be bound to libtest.so.1 (this is written to the executable, see ldd(1) ). If your distribution changes libtest to fix errors, the new version may give libtest.so.1.6 . As long as no changes are made to ABI, everything is working fine. And the fact that there are no API changes is signaled by an unchanged version number 1.

Suppose busy libtest beavers libtest up with a new, all-brilliant, rewritten library from scratch with a modified ABI. As the ABI changes, they change the version number to 2. You install it, and now you have the chain libtest.so --> libtest.so.2 --> libtest.so.2.1 . Please note: now you have installed versions 1 and 2. Your previous programs still work fine using libtest.so.1 , but if you compile a new program, the compiler (linker, really) will pick libtest.so and thus indicate executable file on the new libtest.so.2.1 .

Please note that therefore version numbers should not have anything to do with source code version numbers; the primary number is the ABI version, the minor number is optional and can be used to track changes. So here (Fedora 20) I use systemd-libs-208-15.fc20.x86_64 , which provides libsystemd-daemon.so.0.0.10 .

+14
source share

These are different versions of the same library.

Usually you need the latest stable version of the library, so you refer to x.so, which is associated with the latest version. When the new version becomes available, say, x.so.2, you can use its entire system by linking x.so with x.so.2

Sometimes you want to link to an old version — for example, if your program relies on a quirk that is “fixed” or the latest version introduced an error. Sometimes you want to link to a new experimental version - for example, if you are testing it or fixing a bug in the current version. In this case, you will refer directly to the numbered version - I hope, as a temporary measure.

+2
source share

All Articles