Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why do we need .so.1 file in Linux?

In Linux, for shared libraries, I usually see .so, .so.1 and .so.1.0 files of one library. For example, library test should be presented by libtest.so libtest.so.1 libtest.so.1.0 files. As my understand, .so.1.0 contains real data; .so is linked to .so.1.0 and is used in linking. But I don't understand the purpose of .so.1 file. Could someone clarify the use of .so.1 file? Thanks.

like image 973
river_stone Avatar asked Mar 07 '14 18:03

river_stone


People also ask

What is the use of .so file?

An SO file is a shared library used by programs installed on the Linux and Android operating systems. It contains common program functions and logic that multiple programs require access to.

What are .so files in Linux?

Files with the “. so” extension are dynamically linked shared object libraries. These are often referred to more simply as shared objects, shared libraries, or shared object libraries. Shared object libraries are dynamically loaded at run time.

What is a so 1?

A staff officer of the first class, usually an officer of commander, lieutenant colonel or wing commander rank.

What is the difference between .so and so 1?

Yes, the ". 1" indicates the version number. This makes it possible to have multiple versions of the same library side-by-side, whereas the most common version has a link with no version number. If there is no need to distinguish between different versions, the version suffix might not be present.


1 Answers

Let's 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 links to libtest.so.1.5.

An executable using libtest will link against libtest.so which is libtest.so.1 in this case (this is written into the executable, see ldd(1)). If your distribution changes libtest to fix bugs, the new version might give libtest.so.1.6 (and after update libtest.so.1 links to it, running programs will still use libtest.so.1.5 until they exit). As long as no ABI changes are made, everything works fine. And the fact that there are no API changes is signalled by the unchanged 1 version number.

Let's say the busy libtest beavers come up with a new, all shiny, rewritten from scratch library, with changed ABI. As the ABI changed, they change the major version number to 2. You install that one, and now you have the chain libtest.so --> libtest.so.2 --> libtest.so.2.1. Note you have now both versions 1 and 2 installed. Your earlier programs still work fine, using libtest.so.1, but if you compile a new program the compiler (linker, really) will pick up libtest.so and thus point the executable at the new libtest.so.2.1 (unless specifically asked to use the old version, that is).

Note that the so version numbers don't need to have any relationship to the source code version numbers; the major number is ABI version, the minor number is optional and can be used to track revisions. So here (Fedora 20) I'm using systemd-libs-208-15.fc20.x86_64, which provides libsystemd-daemon.so.0.0.10.

like image 125
vonbrand Avatar answered Sep 27 '22 01:09

vonbrand