1

I once build and installed gcc and binutils with a wrong prefix (--prefix=/home/.../usr) passed to the configure script.

Now I reconfigured, rebuilt and reinstalled gcc and binutils with the right prefix (--prefix=/usr), however compiling always fails with:

$ /bin/ld: cannot find /home/../usr/lib/libc.so.6

Of course I could symlink the libraries in order to get it working, but I would like to know in which file these paths are saved and how I can change them.

alk
  • 69,737
  • 10
  • 105
  • 255
Paul Wolfger
  • 106
  • 1
  • 1
  • 7
  • 2
    What does your `/etc/ld.so.conf` say? – favoretti Jan 01 '13 at 17:28
  • 3
    And when compiling with `gcc -v` what does that say? Also, don't forget to run `ldconfig` – Basile Starynkevitch Jan 01 '13 at 17:36
  • I suggest running `ldd /bin/ld`; it probably is looking for the C library in the wrong place. Until you can re-rebuild it (and re-reinstall it), it is likely to continue to look in the wrong place. As a temporary band-aid, create a symlink in the 'wrong' place that points to `/lib/libc.so.6`. That might well let it work sufficiently to be going on with. Be very, very careful about replacing the system's own compiler tools; I've never risked it, and always install my own versions in separate directories (e.g. in `/usr/gnu` or `/usr/gcc`). If you overwrite the system build, back it up first. – Jonathan Leffler Jan 01 '13 at 18:22
  • @Basile Starynkevitch: gcc -v prints the right prefix (--prefix=/usr). – Paul Wolfger Jan 01 '13 at 22:29
  • @favoretti: I have no file /etc/ld.so.conf there's just an empty directory /etc/ld.so.conf.d/ – Paul Wolfger Jan 01 '13 at 22:31
  • @Jonathan Leffler: I shoud have said that the system is a raspberry pi for which I build my own root fs, so I didn't replace an existing gcc. ldd /bin/ld says: $libz.so.1 => /usr/lib/libz.so.1 (0x401d1000) $ libdl.so.2 => /lib/libdl.so.2 (0x400d4000) $ libgcc_s.so.1 => /usr/lib/libgcc_s.so.1 (0x4008b000) $ libc.so.6 => /lib/libc.so.6 (0x401ec000) $ /lib/ld-linux.so.3 (0x40056000) Symlinking works, however I would like to have a "clean" system – Paul Wolfger Jan 01 '13 at 22:59
  • I can't help very much more — I'm sorry. I only ever expected the symlink to be a transitional stage while you used the existing ('flawed') build to rebuild `bin-utils` with your preferred locations. However, I've not built for Raspberry Pi (nor, indeed, have I built bin-utils for a few years now), so I'm not sure what to suggest. – Jonathan Leffler Jan 01 '13 at 23:08
  • @JonathanLeffler: I cross compiled all these progams. However even a native build of gcc on the Raspberry did not solve the problem. Anyway, thank your for your help! – Paul Wolfger Jan 09 '13 at 21:34

1 Answers1

0

Now I reconfigured, rebuilt and reinstalled gcc and binutils with the right prefix (--prefix=/usr), however compiling always fails with:

$ /bin/ld: cannot find /home/../usr/lib/libc.so.6

You probably have not rebuilt and re-installed libc, and the error comes from it.

On Linux, libc.so is a linker script, similar to this:

/* GNU ld script
   Use the shared library, but some functions are only in
   the static library, so try that secondarily.  */
OUTPUT_FORMAT(elf64-x86-64)
GROUP ( /lib/x86_64-linux-gnu/libc.so.6 /usr/lib/x86_64-linux-gnu/libc_nonshared.a  AS_NEEDED ( /lib/x86_64-linux-gnu/ld-linux-x86-64.so.2 ) )

I bet your libc.so has /home/../usr/lib/libc.so.6 in it.

Community
  • 1
  • 1
Employed Russian
  • 199,314
  • 34
  • 295
  • 362