Multiple glibc libraries on a single host

后端 未结 11 1855
轮回少年
轮回少年 2020-11-21 05:13

Multiple glibc libraries on a single host

My linux (SLES-8) server currently has glibc-2.2.5-235, but I have a program which won\'t work on this version and requires

11条回答
  •  生来不讨喜
    2020-11-21 05:42

    "Employed Russian" is among the best answer, and I think all other suggested answer may not work. The reason is simply because when an application is first created, all its the APIs it needs are resolved at compile time. Using "ldd" u can see all the statically linked dependencies:

    ldd /usr/lib/firefox/firefox
        linux-vdso.so.1 =>  (0x00007ffd5c5f0000)
        libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007f727e708000)
        libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007f727e500000)
        libstdc++.so.6 => /usr/lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007f727e1f8000)
        libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f727def0000)
        libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f727db28000)
        /lib64/ld-linux-x86-64.so.2 (0x00007f727eb78000)
        libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007f727d910000)
    

    But at runtime, firefox will also load many other dynamic libraries, eg (for firefox) there are many "glib"-labelled libraries loaded (even though statically linked there are none):

     /usr/lib/x86_64-linux-gnu/libdbus-glib-1.so.2.2.2
     /lib/x86_64-linux-gnu/libglib-2.0.so.0.4002.0
     /usr/lib/x86_64-linux-gnu/libavahi-glib.so.1.0.2
    

    Manytimes, you can see names of one version being soft-linked into another version. Eg:

    lrwxrwxrwx 1 root root     23 Dec 21  2014 libdbus-glib-1.so.2 -> libdbus-glib-1.so.2.2.2
    -rw-r--r-- 1 root root 160832 Mar  1  2013 libdbus-glib-1.so.2.2.2
    

    This therefore means different version of "libraries" exists in one system - which is not a problem as it is the same file, and it will provide compatibilities when applications have multiple versions dependencies.

    Therefore, at the system level, all the libraries are almost interdependent on one another, and just changing the libraries loading priority via manipulating LD_PRELOAD or LD_LIBRARY_PATH will not help - even it can load, runtime it may still crash.

    http://lightofdawn.org/wiki/wiki.cgi/-wiki/NewAppsOnOldGlibc

    Best alternative is chroot (mentioned by ER briefly): but for this you will need to recreate the entire environment in which is the original binary execute - usually starting from /lib, /usr/lib/, /usr/lib/x86 etc. You can either use "Buildroot", or YoctoProject, or just tar from an existing Distro environment. (like Fedora/Suse etc).

提交回复
热议问题