How to associate with a specific name (version) of a shared library

I searched for this problem here and found some kind of similar question, but the solutions for me do not work. Here is my problem: My application compiles with the openldap-2.3 shared library. Openldap has / usr / lib / libldap -2.3.so.0, which is associated with / usr / lib / libldap -2.3.so.0.2.31. I passed the -lldap to gcc, which linked the libldap-2.3.so.0 file with my application.

But I want to associate with a specific name, for example libldap.so. Please correct me , in the future, if I change the version of openldap to version 2.4 in the development system, it will refer to version libldap-2.4.so.XXX.

So, how can I associate my application with a specific name so that it will always look for the same name as libldap.so.

NOTE. . I created the program link / usr / lib / libldap -2.3.so.0 as / usr / lib / libldap.so and then passed the library name /usr/lib/libldap.so compiler without -l , then the application compiled successfully without which any binding errors, but still showing the same libldap-2.3.so.0 depending.

+4
source share
1 answer

the shared library mechanism (the link is old but relevant) in Unix works by linking the executable file during build against, for example. liba.so, which is a symbolic link to liba.so.1, which, in turn, is a link to liba.so.1.2. Then the executable writes liba.so.1 to load at startup. If you update liba.so, it could be liba.so.1.5 (without changing the ABI, the first digit does not change), the links look like liba.so → liba.so.1 → liba.so.1.5, and your executable is now uses 1.5 transparently. If the version goes to liba.so.2.0 (API change!), The system does liba.so -> liba.so.2 -> liba.so.2.0. Your old executable is still using 1.5, any new program will now reference 2. This all works as long as 1.x stays around, obviously. Presumably, your distribution offers library packages that can be installed in parallel or in the compat-liba-1 package for old executables.

+1
source

All Articles