# Just how do SO (shared object) numbers function?

I'm mindful that common things under Linux make use of "so numbers", particularly that various variations of a common object are offered various expansions, as an example:

• example.so.1
• example.so.2

I recognize the suggestion is to have 2 distinctive documents such that 2 variations of a collection can feed on a system (in contrast to "DLL Hell" on Windows). I would certainly such as to recognize just how this operates in technique? Usually, I see that example.so remains in reality a symbolic link to example.so.2 where .2 is the most up to date variation. Just how after that does an application relying on an older variation of example.so recognize it appropriately? Exist any kind of regulations regarding what leadings must make use of? Or is this merely convention? Is it the instance that, unlike in Windows where software program binaries are moved in between systems, if a system has a more recent variation of a common object it is connected to the older variation instantly when assembling from resource?

I believe this relates to ldconfig yet I'm not exactly sure just how.

0
2019-05-06 02:21:15
Source Share

libNAME.so is the filename made use of by the compiler/linker when first seeking a collection defined by - lNAME. Inside a common collection documents is an area called the SONAME. This area is set when the collection itself is first connected right into a common object (so) by the construct procedure. This SONAME is in fact what a linker shops in an executable relying on that shared object is related to it. Generally the SONAME remains in the kind of libNAME.so.MAJOR and also is transformed anytime the collection comes to be inappropriate with existing executables connected to it and also both significant variations of the collection can be maintained mounted as required (though just one will certainly be indicated for growth as libNAME.so) Also, to sustain conveniently updating in between small variations of a collection, libNAME.so.MAJOR is generally a link to a documents like libNAME.so.MAJOR.MINOR. A new small variation can be mounted and also as soon as finished, the link to the old small variation is bumped to indicate the new small variation quickly updating all new implementations to make use of the updated collection. Additionally, see my response to Linux, GNU GCC, ld, version scripts and the ELF binary format -- How does it work?

0
2019-05-31 16:18:04
Source

The numbers in the common collections are convention made use of in Linux to recognize the API of a collection. Commonly the layout is :

libFOO.so.MAJOR.MINOR

.

And also as you saw generally there is a symbolic link from libFOO.so to libFOO.so.MAJOR.MINOR. ldconfig is in charge of upgrading this link to the latest variation.

The MAJOR is commonly incremented when the API adjustments (new access factors are gotten rid of or the parameters or kinds transformed). The MINOR commonly is incremented for bug solution launches or when new APIs are presented without damaging existing APIs.

An extra considerable conversation can be located below : Dissecting shared libraries

0
2019-05-08 10:34:58
Source

Binaries themselves recognize which variation of a common collection they rely on, and also demand it especially. You can make use of ldd to show the dependences ; mine for ls are :

\$ ldd /bin/ls
linux-gate.so.1 =>  (0xb784e000)
librt.so.1 => /lib/librt.so.1 (0xb782c000)
libacl.so.1 => /lib/libacl.so.1 (0xb7824000)
libc.so.6 => /lib/libc.so.6 (0xb76dc000)

As you can see, it indicates as an example libpthread.so.0, not simply libpthread.so.
The factor for the symbolic link is for the linker. When you intend to link versus libpthread.so straight, you offer gcc the flag -lpthread, and also it adds the lib prefix and also .so suffix instantly. You can not inform it to add the .so.0 suffix, so the symbolic link indicate the latest variation of the lib to faciliate that