Loading multiple shared libraries with different versions

后端 未结 2 1451
梦谈多话
梦谈多话 2020-12-08 06:12

I have an executable on Linux that loads libfoo.so.1 (that\'s a SONAME) as one of its dependencies (via another shared library). It also links to a

相关标签:
2条回答
  • 2020-12-08 06:17

    I can only come up with a work-around. Which would be to statically link a version of the "system library" that you are using. For your static build, you could make it link against the same old version as the third-party library. Given that it does not rely on the newer version...

    Perhaps it is also possible to avoid these problems with not linking to the third-party library the ordinary way. Instead, your program could load it at execution time. Perhaps then it could be shadowed against the rest. But I don't know much about that.

    0 讨论(0)
  • 2020-12-08 06:27

    You may be able to do some version script tricks:

    http://sunsite.ualberta.ca/Documentation/Gnu/binutils-2.9.1/html_node/ld_26.html

    This may require that you write a wrapper around your lib that pulls in libfoo.so.1 that exports some symbols explicitly and masks all others as local. For example:

    MYSYMS { global: foo1; foo2; local: *; };

    and use this when you link that wrapper like:

    gcc -shared -Wl,--version-script,mysyms.map -o mylib wrapper.o -lfoo -L/path/to/foo.so.1

    This should make libfoo.so.1's symbols local to the wrapper and not available to the main exe.

    0 讨论(0)
提交回复
热议问题