[lug] Shared libraries

Zan Lynx zlynx at acm.org
Mon Nov 9 17:14:10 MST 2009


On 11/9/09 4:52 PM, Jeffrey Haemer wrote:
> I have a build where the link line contains "-lssh2" .  I have only
> /usr/lib/libssh2.1 and /usr/lib/libssh2.1.0.0
>
> ldconfig will figure out to symlink libssh2.so.1.0.0 to libssh2.so.1, if
> it isn't linked already.  (It is.)  Do I have to manually link
> libssh2.so.1 to libssh2.so , or should some other utility be doing that?
>
> (I did the link by hand, so I'm really asking, "What should I have done?")
>

ldconfig will create the link for the library's SONAME. The SONAME is 
written into the ELF header. You can see it with "readelf -d 
/lib/libc.so.6" (for example).

When a program is built (with GCC for example) it links against the 
SONAME of each shared library.

So there are two symlinks. One is made by ldconfig. This one is from a 
very specific library version to a more general version. The other 
symlink is for building against the library and it is the *most* general 
version and is usually linked to the most recent version.

Programs need /usr/lib/libssh2.so.1.0.0 and libssh2.so.1 in order to 
run. They need /usr/lib/libssh2.so in order to build.

In RedHat world, the -devel package usually contains the 
/usr/lib/libssh2.so symlink needed for building.

-- 
Zan Lynx
zlynx at acm.org

"Knowledge is Power.  Power Corrupts.  Study Hard.  Be Evil."



More information about the LUG mailing list