lfs-book, version 6.4, chapter 6.7, "make: gcc: Command not found"

Ken Moffat ken at linuxfromscratch.org
Sat Feb 14 09:11:04 PST 2009


On Sat, Feb 14, 2009 at 09:54:45AM +0100, Aaron Schawalder wrote:
> Chris Staub wrote:
> > Aaron Schawalder wrote:
> >   
> >> Something is wrong ...
> >>
> >> I performed the following tests:
> >> /home/lfs is the home directory of user "lfs"
> >>
> >> root:/sources/linux-2.6.27.4# exit
> >> logout
> >> esprit:/home/lfs# echo $LFS
> >> /mnt/lfs
> >> esprit:/home/lfs# readelf -l /tools/bin/gcc | grep interpret
> >>      [Requesting program interpreter: /lib/ld-linux.so.2]
> >> esprit:/home/lfs#
> >>     
> >
> > I don't see the point of this. You're neither the lfs user nor inside 
> > chroot - this is just as a regular user, so you're only testing the host 
> > system's gcc.
> >
> >   
> The point here is, that I was user "lfs" and went "su" and performed 
> "readelf -l /tools/bin/gcc | grep interpret". So I performed the readelf 
> for /tools/bin/gcc as root but not in chroot.
> 
 I'm having some trouble following this (I've got a cold so my
concentration is down and this has got rather long), so what I say
may need to be taken with an even bigger pinch of salt than usual ;-)
> >
> > Obviously "cc" isn't going to be found if /tools/bin isn't in the PATH.
> >   
> When I am logged in as user "lfs" and I am not in the chroot 
> environment, I get:
> 
> lfs at esprit:~$ echo $LFS
> /mnt/lfs
> lfs at esprit:~$ echo $PATH
> /tools/bin:/bin:/usr/bin
> lfs at esprit:~$
> 
> So the PATH here is correct.
> 
> Now I go:
> 
> lfs at esprit:~$ cd $LFS
> lfs at esprit:/mnt/lfs$ cd tools/
> lfs at esprit:/mnt/lfs/tools$
> 
> Now clearly I get:
> 
> lfs at esprit:/mnt/lfs/tools$ echo 'main(){}' > dummy.c
> bash: dummy.c: Permission denied
> lfs at esprit:/mnt/lfs/tools$
> 
> because
> 
> lfs at esprit:/mnt/lfs$ vdir 
> ....
> drwxr-xr-x 11 root root  4096 Feb 14 08:35 tools
> ...
> lfs at esprit:/mnt/lfs$
> 
> what is correct.
 That is correct, in section 5.34 you changed the ownership.  After
that, the only purpose of using the lfs user is to set up your
environment before you 'su'.

[...]
> Then I go su because I can do chroot only as root:
> 
> lfs at esprit:~$ su
> Password:
> esprit:/home/lfs#
> 
> Now I performe chroot:
> 
> esprit:/home/lfs# chroot /mnt/lfs /tools/bin/env -i HOME=/root 
> TERM="$TERM" PS1='\u:\w\$ ' 
> PATH=/bin:/usr/bin:/sbin:/usr/sbin:/tools/bin /tools/bin/bash --login +h
> root:/#
> 
> Now echo $PATH gives:
> 
> root:/# echo $PATH
> /bin:/usr/bin:/sbin:/usr/sbin:/tools/bin
> root:/#
> 
> Now I perform:
> 
> root:/tools# echo 'main(){}' > dummy.c
> root:/tools# cc dummy.c
> bash: /tools/bin/cc: No such file or directory
> root:/tools#
> 
> 
> 
> >> New login as user "lfs" just as in chapter 5:
 Snipping here, you've now lost me completely.

 First, please review the essential files and symlinks which you
should have created in section 6.6, to make sure they all exist in
the new system.  I'm particularly wondering if you missed libgcc_s.

 If they are all present, from a clean entry into chroot (as user
lfs, ensuring the mounts in section 6.2 exist, then using the chroot
command from section 6.4):

type -p cc
 assuming it does point to a file,
ls -l $(type -p cc)

 if this does indeed point to /tools/bin/gcc,
run the readelf command again (while still inside chroot).
If it shows gcc is using /lib/ld-linux.so.2 you will have to start
again as Chris advised.

 OTOH, if it shows gcc is using /tools/lib/ld-linux.so.2 you should
then run 'ldd /tools/bin/gcc' to see which library or libraries is
not found.

ĸen
-- 
das eine Mal als Tragödie, das andere Mal als Farce



More information about the lfs-support mailing list