tags:

views:

458

answers:

2

G'day,

on a 64bit RHEL5 box we need to install our 32bit application. For some reasons we need to use gcc 4.0.3 for this, so I tried to install that version on the target machine first, like I did a thousand times on 32bit target platforms.

This time, however, I am experiencing problems. I have bootstrapped and instaled gcc 4.0.3 into a path, let's say /foo. Like always I set the LD_LIBRARY_PATH to point into the directory containing shared libraries:

 $ echo $LD_LIBRARY_PATH
/foo/lib:/foo/lib/gcc/x86_64-unknown-linux-gnu/lib64:/foo/lib/gcc/x86_64-unknown-linux-gnu/4.0.3:/lib64

There really are the necessary libraries in these directories:

 $ ls /foo/lib/gcc/x86_64-unknown-linux-gnu/lib64
libgcc_s.so  libgcc_s.so.1
 $ ls /foo/lib/gcc/x86_64-unknown-linux-gnu/4.0.3
32           crtendS.o      libgcov.a        libmudflap.so.0.0.0  libmudflapth.so.0.0.0  libstdc++.so.6.0.7
crtbegin.o   include        libmudflap.a     libmudflapth.a       libstdc++.a            libsupc++.a
crtbeginS.o  install-tools  libmudflap.la    libmudflapth.la      libstdc++.la           libsupc++.la
crtbeginT.o  libgcc.a       libmudflap.so    libmudflapth.so      libstdc++.so
crtend.o     libgcc_eh.a    libmudflap.so.0  libmudflapth.so.0    libstdc++.so.6

However, if I try to create a simple program, ld can't find libgcc_s:

 $ gcc-4.0 t.cc
/foo/bin/../lib/gcc/x86_64-unknown-linux-gnu/4.0.3/../../../../x86_64-unknown-linux-gnu/bin/ld: cannot find -lgcc_s
collect2: ld returned 1 exit status

Why doesn't it find the libgcc_s.so library?

Any help appreciated!

Stefan

A: 
 $ gcc-4.0 -v t.cc
Using built-in specs.
Target: x86_64-unknown-linux-gnu
Configured with: ../gcc-4.0.3/configure --prefix=/foo --program-suffix=-4.0 --enable-version-specific-runtime-libs --enable-languages=c,c++ --with-gnu-as --with-gnu-ld
Thread model: posix
gcc version 4.0.3
 /foo/i686-pc-linux-gnu/bin/../libexec/gcc/x86_64-unknown-linux-gnu/4.0.3/cc1plus -quiet -v -iprefix /foo/i686-pc-linux-gnu/bin/../lib/gcc/x86_64-unknown-linux-gnu/4.0.3/ -D_GNU_SOURCE t.cc -quiet -dumpbase t.cc -mtune=k8 -auxbase t -version -o /tmp/ccDiWiMk.s
ignoring nonexistent directory "/foo/i686-pc-linux-gnu/bin/../lib/gcc/x86_64-unknown-linux-gnu/4.0.3/../../../../x86_64-unknown-linux-gnu/include"
ignoring duplicate directory "/foo/lib/gcc/x86_64-unknown-linux-gnu/4.0.3/include/c++"
ignoring duplicate directory "/foo/lib/gcc/x86_64-unknown-linux-gnu/4.0.3/include/c++/x86_64-unknown-linux-gnu"
ignoring duplicate directory "/foo/lib/gcc/x86_64-unknown-linux-gnu/4.0.3/include/c++/backward"
ignoring duplicate directory "/foo/lib/gcc/x86_64-unknown-linux-gnu/4.0.3/include"
ignoring nonexistent directory "/foo/lib/gcc/x86_64-unknown-linux-gnu/4.0.3/../../../../x86_64-unknown-linux-gnu/include"
#include "..." search starts here:
#include  search starts here:
 /foo/i686-pc-linux-gnu/bin/../lib/gcc/x86_64-unknown-linux-gnu/4.0.3/include/c++
 /foo/i686-pc-linux-gnu/bin/../lib/gcc/x86_64-unknown-linux-gnu/4.0.3/include/c++/x86_64-unknown-linux-gnu
 /foo/i686-pc-linux-gnu/bin/../lib/gcc/x86_64-unknown-linux-gnu/4.0.3/include/c++/backward
 /foo/i686-pc-linux-gnu/bin/../lib/gcc/x86_64-unknown-linux-gnu/4.0.3/include
 /usr/local/include
 /foo/include
 /usr/include
End of search list.
GNU C++ version 4.0.3 (x86_64-unknown-linux-gnu)
        compiled by GNU C version 4.1.2 20080704 (Red Hat 4.1.2-46).
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
 /foo/i686-pc-linux-gnu/bin/../lib/gcc/x86_64-unknown-linux-gnu/4.0.3/../../../../x86_64-unknown-linux-gnu/bin/as -V -Qy -o /tmp/ccAemlDJ.o /tmp/ccDiWiMk.s
GNU assembler version 2.19.1 (x86_64-unknown-linux-gnu) using BFD version (GNU Binutils) 2.19.1
 /foo/i686-pc-linux-gnu/bin/../libexec/gcc/x86_64-unknown-linux-gnu/4.0.3/collect2 --eh-frame-hdr -m elf_x86_64 -dynamic-linker /lib64/ld-linux-x86-64.so.2 /usr/lib/../lib64/crt1.o /usr/lib/../lib64/crti.o /foo/i686-pc-linux-gnu/bin/../lib/gcc/x86_64-unknown-linux-gnu/4.0.3/crtbegin.o -L/foo/i686-pc-linux-gnu/bin/../lib/gcc/x86_64-unknown-linux-gnu/4.0.3 -L/foo/i686-pc-linux-gnu/bin/../lib/gcc -L/foo/lib/gcc/x86_64-unknown-linux-gnu/4.0.3 -L/foo/i686-pc-linux-gnu/bin/../lib/gcc/x86_64-unknown-linux-gnu/4.0.3/../../../../x86_64-unknown-linux-gnu/lib -L/foo/lib/gcc/x86_64-unknown-linux-gnu/4.0.3/../../../../x86_64-unknown-linux-gnu/lib -L/foo/i686-pc-linux-gnu/bin/../lib/gcc/x86_64-unknown-linux-gnu/4.0.3/../../../../lib64 -L/foo/i686-pc-linux-gnu/bin/../lib/gcc/x86_64-unknown-linux-gnu/4.0.3/../../.. -L/foo/lib/gcc/x86_64-unknown-linux-gnu/4.0.3/../../../../lib64 -L/foo/lib/gcc/x86_64-unknown-linux-gnu/4.0.3/../../.. -L/lib/../lib64 -L/usr/lib/../lib64 /tmp/ccAemlDJ.o -lgcc --as-needed -lgcc_s --no-as-needed -lc -lgcc --as-needed -lgcc_s --no-as-needed /foo/i686-pc-linux-gnu/bin/../lib/gcc/x86_64-unknown-linux-gnu/4.0.3/crtend.o /usr/lib/../lib64/crtn.o
/foo/i686-pc-linux-gnu/bin/../lib/gcc/x86_64-unknown-linux-gnu/4.0.3/../../../../x86_64-unknown-linux-gnu/bin/ld: cannot find -lgcc_s
collect2: ld returned 1 exit status
struppi
+1  A: 

It seems your folder /foo/lib/gcc/x86_64-unknown-linux-gnu/lib64 where libgcc_s.so is not included. For the sake of experiment do this:

gcc-4.0 -v t.cc -L/foo/lib/gcc/x86_64-unknown-linux-gnu/lib64

skwllsp
Yes, that worked. Thank you very much for pointing me in the right direction!I now set symbolic links in ...x86_64-unknown-linux-gnu/4.0.3 to point to ../lib64/libgcc_s.so and ../lib64/libgcc_s.so.1 and now it runs fine.Might be a problem in the build of gcc 4.0.3 in 64 bit environments.
struppi