Two versions of the same library in one application

I have two versions (with an almost identical API) of the same shared library. I have to use them in one application. I know how to resolve name conflicts in headers - I just import them as

namespace version1 {
    #include "version1/library.h"
}

namespace version2 {
    #include "version2/library.h"
}

I don’t know how I decide to bind conflicts - the library is dynamically linked. The first version creates the following structure in the user lib folder:

libsomething.so -> libsomething.so.2
libsomething.so.2 -> libsomething.so.0.8.31.1
libsomething.so.0.8.31.1

second:

libsomething.so -> libsomething.so.2
libsomething.so.2 -> libsomething.so.0.8.32
libsomething.so.0.8.32

My target environment is a Linux machine.

Context:

, , - CMakeProject lib, , . , , . . , , , libs ( , - , , ​​ , ).

+4
1

- Linux.

, , , SONAME, libsomething.so.2.

Linux runtime. .

, , - , dlopen (3). dlsym (3) dlsymv3 (3), .

, dlsym() dlsymv3() . , .

, , , .

0

Source: https://habr.com/ru/post/1689062/


All Articles