cross compile

Jeremy Huntwork jhuntwork at
Wed Jun 29 04:30:23 PDT 2005

henk wrote:
> "By putting /tools/bin ahead of the standard PATH, all the programs
> installed in Constructing a Temporary Tools are picked up by the shell
> immediately after their installation. This, combined with turning off
> hashing, limits the risk that old programs from the host are being used when
> they should not be used any longer. "
> Could it be that the references to /cross-tools and /tools are mixed-up.
> Should I use cross-tools where tools is mentioned?

The commands in the book should be correct. (There may be bugs because 
of ongoing book organization/development.) The explanatory text though 
likely isn't fully up to speed with the commands.

Anyway, let me break the concept down for you a little bit. The new 
cross-lfs has two temporary directories:

~/cross-tools  (notice that this one is in the home directory of 'lfs' - 
likely /home/lfs, but you never know)

The root user, as usual, creates a symlink on the root tree to $LFS/tools:

ln -s $LFS/tools / (thus giving you /tools)

After you set up the lfs user and its environment, you exit back to the 
root user momentarily and create a symlink on the root tree to the 
location of lfs's ~/cross-tools, then su into lfs again:

LFSHOME=`su - lfs -c 'echo $HOME'`
ln -s $LFSHOME/cross-tools /   (this should give you /cross-tools)
su - lfs

The purpose of /tools pretty much the same as it was in previous books. 
It provides a set of temporary tools which allow you to natively build 
the final LFS system.  /cross-tools, obviously is new. Its purpose is to 
house an installation of a cross compiler and linker.

Imagine for a moment that you are using the book to compile for another 
arch, say x86 to ppc.  The cross compilers, in cross-tools will be x86 
binaries that produce ppc executables. Those ppc executables will be 
installed into /tools. So until you have the /tools directory filled 
with a temporary toolset and you're ready to boot into the ppc machine, 
you won't be able to run any of the binaries installed there, as they're 
for a different arch.  That's why we have the path set up the way it is. 
We want to find our cross-compiler/linker first before the hosts native 
ones, and we don't want to execute anything in /tools before we chroot 
or reboot into the target machine.

Anyway, all this is to say that your error is probably connected with 
something else. Could you please reply with details on the error, ie., 
where in the build it occurs exactly (which section) and what exactly 
the error says.



More information about the lfs-support mailing list