Why is /lib/libc.so.6 missing?

find | grep libc.so.6

reveals that it's in /lib/i386-linux-gnu/libc.so.6, but a script I was running expected it to be directly under /lib, so why isn't there at least a symlink?

Would I risk breaking anything if I put a symlink there?


libc.so was moved as part of the multiarch work in Ubuntu 11.04. The reason that there can't be a symlink there is that the purpose of multiarch is to make it possible to install both the i386 and amd64 versions of libc at the same time so that you can run 32-bit binaries more easily on 64-bit systems and vice versa (and other similar situations). If the libc6 package contained a symlink to the new location, then the versions of that package for different architectures wouldn't both be installable at the same time (which version of the symlink would dpkg pick?), defeating the entire point of the exercise.

Anything that hardcodes the path to libc.so must be updated to work properly from Ubuntu 11.04 onwards. If the script you're talking about is part of Ubuntu, please report a bug on it and add the multiarch tag.


Dynamic libraries are loaded by the kernel, the paths are not hardcoded in a program. A program just says "I need libc.so.6". The system then searches in library paths as defined in /etc/ld.so.conf, including /usr/lib and /lib by default. This file includes additional configuration files in /etc/ld.so.conf.d.

On my 64 bits system, libc.so.6 can be found in /lib/x86_64-linux-gnu/libc.so.6 because of the path defined in /etc/ld.so.conf.d/x86_64-linux-gnu.conf:

# Multiarch support
/lib/x86_64-linux-gnu
/usr/lib/x86_64-linux-gnu

To find out what library is loaded by a program, use ldd as in ldd /bin/bash:

    linux-vdso.so.1 =>  (0x00007ffff1dff000)
    libncurses.so.5 => /lib/libncurses.so.5 (0x00007f9d8b3b8000)
    libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007f9d8b1b4000)
    libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f9d8ae1f000)
    /lib64/ld-linux-x86-64.so.2 (0x00007f9d8b61c000)

Putting the symlink would not break anything.

To get a list of directories that are searched, run:

ldconfig -v -N | grep '^/'

-v causes a list of file + directories to be shown, -N prevents the cache (/etc/ld.so.cache) from being recreated.