What to do when two shared libraries depend on the same version of a third-party group compiled differently?

My application depends on a specific version of xerces (compiled with certain flags):

$ ldd actimize_intelligence_server | grep xerces libxerces-c.so.28 => ./libxerces-c.so.28 (0x00002b3c1518f000) 

The shared library (received from the client) also depends on xerces (apparently compiled with different flags):

 $ ldd libgqt.so | grep xerces libxerces-c.so.28 => ./bin/libxerces-c.so.28 (0x00002b1f3d28f000) 

Attempting to run the application gives this error:

 symbol lookup error: libgqt.so: undefined symbol: _ZN11xercesc_2_825DOMImplementationRegistry20getDOMImplementationEPKt 

Invalid character:

xercesc_2_8 :: DOMImplementationRegistry :: getDOMImplementation (unsigned short const *)

So far, the exported character from my libxerces-c.so.28 is as follows:

xercesc_2_8 :: DOMImplementationRegistry :: getDOMImplementation (wchar_t const *)

So I guess that is the problem. Running strace when starting the application showed that my libxerces-c.so.28 :

 open("/home/test/app/libxerces-c.so.28", O_RDONLY) = 3 read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0\0\365\31\0\0\0\0\0"..., 832) = 832 fstat(3, {st_mode=S_IFREG|0555, st_size=5757256, ...}) = 0 mmap(NULL, 6791128, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x2ba744950000 mprotect(0x2ba744e82000, 1044480, PROT_NONE) = 0 mmap(0x2ba744f81000, 299008, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x531000) = 0x2ba744f81000 close(3) 

Without additional occurrences of libxerces-c.so.28 .

And so my little knowledge of Linux ends.

Is there any way to get another libxerces-c.so.28 to load, even if it is already loaded?
If not, do I have any other options besides telling my client that he needs to recompile his code to make it work with our xers?

+4
source share
2 answers

You cannot do this. Do not mess with binary compatibility, for example: if you want to dynamically link to the same library, it must be compiled the same way.

+3
source

You did not say that you need libgqt.so , and how much your application depends on it.

If you really are not dependent on libgqt.so and just use a few characters from it to do something for this particular client, then dlmopen(LM_ID_NEWLM, "libgqt.so", RTLD_NOW) may be a viable solution. The documentation is here .

In general, DeadMG is true: it’s best to make sure that you use the same xerces compilation, or that you will be injured sooner or later.

Note that static xerces bindings in your application are unlikely to be viable. It seems that everything will work, only in case of unpredictable time later.

+1
source

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


All Articles