Loading multiple shared libraries with different versions

后端 未结 2 1454
梦谈多话
梦谈多话 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: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.

提交回复
热议问题