What is the difference between /lib/i386-linux-gnu/libc.so.6, /lib/x86_64-linux-gnu/libc.so.6 and /usr/lib/x86_64-linux-gnu/libc.so?

后端 未结 3 1782
星月不相逢
星月不相逢 2020-12-30 10:19

I installed Matlab in my Linux Mint 14 Nadia (a uname -a shows: Linux Ideapad-Z570 3.5.0-17-generic #28-Ubuntu SMP Tue Oct 9 19:31:23 UTC 2012 x86_64 x86_64 x86_64 GNU/Linux

相关标签:
3条回答
  • 2020-12-30 10:42

    To find which one to use, you have to first find the order that ld (the linker) uses to find libraries, like so:

    ld --verbose | grep SEARCH
    

    For me it gave me this output:

    SEARCH_DIR("/usr/x86_64-unknown-linux-gnu/lib64"); SEARCH_DIR("/usr/x86_64-unknown-linux-gnu/lib"); SEARCH_DIR("/usr/lib"); SEARCH_DIR("/usr/local/lib");
    

    This means that on my computer, ld looks in these directories, in order:

    1. /usr/x86_64-unknown-linux-gnu/lib64
    2. /usr/x86_64-unknown-linux-gnu/lib
    3. /usr/lib
    4. /usr/local/lib

    So if libc was in /usr/x86_64-unknown-linux-gnu/lib64, and libc was also in /usr/lib, it would use the /usr/x86_64-unknown-linux-gnu/lib64 version, because it was listed first.

    0 讨论(0)
  • 2020-12-30 10:51

    /lib/i386-linux-gnu/libc.so.6

    This is is 32-bit version of the library.

    /lib/x86_64-linux-gnu/libc.so.6

    This is the 64-bit version of the library.

    Both are usually symbolic links to the actual library file, which will usually be named according to the glibc release number, for example libc-2.15.so

    /usr/lib/x86_64-linux-gnu/libc.so

    This is not a library, but a linker script file, which refers to the above symlinks.

    Why do we need all these:

    First, regardless of libc version installed, the linker will always search for libc.so, because the compiler driver will always pass to the linker the -lc options. The name libc stays the same and denotes to most recent version of the library.

    The symlinks libc.so.6 are named after the soname of the library, which, more or less corresponds to the ABI version of the library. The executables, linked against libc.so in fact contain runtime dependencies on libc.so.6.

    If we imagine the someday a grossly ABI incompatible libc is released, it's soname could be named libc.so.7, for example and this version coukld coexists with the older libc.so.6 version, thus executables linked against one or the other can coexist in the same system,

    And finally, the name libc-2.15.so refers to the libc release, when you install a new libc package, the name will change to libc-2.16.so. Provided that it is binary compatible with the previous release, the libc.so.6 link will stay named that way and the existing executables will continue to work.

    0 讨论(0)
  • 2020-12-30 10:59

    The symlink you created will have no effect whatsoever on GCC. The 32-bit version is only used when you compile using the -m32 GCC flag. GCC will not attempt to generate 32-bit binaries unless you specifically tell it to (by using that flag.)

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