ld can't find stdc++ right after the re-adjustment phase (section6.10)

Angel Tsankov fn42551 at fmi.uni-sofia.bg
Sun Feb 8 01:33:20 PST 2009

Angel Tsankov wrote:
> Frist of all, I'd like to note that I've been following LFS 6.4 not
> very strictly but close enough to think that the problem I've
> encountered might concern LFS 6.4.
> Now to the point. I'm building a LFS system with binutils version
> 2.18 and gcc version 4.3.3 (glibc's version is 2.9-20090202, the
> kernel's version is
> 2.6.28; other packages' versions may also be different from those in
> 6.4)
> and I've just found out that applying the
> '/\*startfile_prefix_spec:/{n;s at .*@/usr/lib/ @}' sed script to
> /tools/lib/gcc/i686-pc-linux-gnu/4.2.4/specs (as per the instruction
> in the re-adjustment phase, section 6.10) prevents ld from finding
> the stdc++ library (which is located in "/tools/lib").  As a result,
> C++ programs fail to link when I try to compile them with g++.  In
> contrast, they do link when I compile them with gcc.  However, GMP
> checks for a C++ compiler by trying to
> compile a simple C++ program with g++ rather than with gcc and
> therefore fails
> to configure.
> I also found that "reverting" the changes from the above-mentioned sed
> script or substituting "/usr/lib/ /tools/lib/" instead of just
> "/usr/lib/ " both help.  However, none of these steps is in the LFS
> book and I wonder if I have gone wrong somewhere.  Also, installing
> binutils (after making the re-adjustments) does not help.
> And, by the way, I had exactly the same problem with bniutils 2.16,
> gcc
> 4.2.4, glibc 2.3.6, and the same kernel version.
The problem was that I had omitted creating the symlinks to stdc++ in
/usr/lib (ln -sv /tools/lib/libstdc++.so{,.6} /usr/lib).  That's why ld did
not find stdc++ though it looked there.  Creating those symlinks fixed the 

Many thanks to ChrisS67 for pointing this to me in #lfs-support,

More information about the lfs-support mailing list