Search code examples
linuxlinux-from-scratch

Linux from Scratch 5.7.2 Toolchain sanity check


I started the Project "Linux from Scratch" some time ago. First I started with Ubuntu 15.10 64bit and did everything according to the PDF-File. By the Check in paragraph 5.7.2, it didn't worked. Afterwards I started all over again, with CentOS 7.2 but it works neither.In both attempts i got no Errors while compiling and installing the previous packages.

Input:

echo 'int main(){}' > dummy.c
$LFS_TGT-gcc dummy.c

Output:

/mnt/lfs/tools/bin/../lib/gcc/x86_64-lfs-linux-gnu/5.3.0/../../../../x86_64-lfs-linux-gnu/bin/ld: cannot find crt1.o: No such file or directory
/mnt/lfs/tools/bin/../lib/gcc/x86_64-lfs-linux-gnu/5.3.0/../../../../x86_64-lfs-linux-gnu/bin/ld: cannot find crti.o: No such file or directory
/mnt/lfs/tools/bin/../lib/gcc/x86_64-lfs-linux-gnu/5.3.0/../../../../x86_64-lfs-linux-gnu/bin/ld: cannot find -lc
/mnt/lfs/tools/bin/../lib/gcc/x86_64-lfs-linux-gnu/5.3.0/../../../../x86_64-lfs-linux-gnu/bin/ld: cannot find crtn.o: No such file or directory
collect2: error: ld returned 1 exit status

Input:

readelf -l a.out | grep ': /tools'

Output:

readelf: Error: 'a.out': No such file

I found no solution that worked in StackOverFlow or different platforms.

Here my Output of the version-check.sh:

lfs:~$ bash version-check.sh
bash, version 4.2.46(1)-release
/bin/sh -> /usr/bin/bash
Binutils: version 2.23.52.0.1-55.el7 20130226
bison (GNU Bison) 2.7
/usr/bin/yacc -> /usr/bin/bison
bzip2,  Version 1.0.6, 6-Sept-2010.
Coreutils:  8.22
diff (GNU diffutils) 3.3
find (GNU findutils) 4.5.11
GNU Awk 4.0.2
/usr/bin/awk -> /usr/bin/gawk
gcc (GCC) 4.8.5 20150623 (Red Hat 4.8.5-4)
g++ (GCC) 4.8.5 20150623 (Red Hat 4.8.5-4)
(GNU libc) 2.17
grep (GNU grep) 2.20
gzip 1.5
Linux version 3.10.0-327.el7.x86_64 ([email protected]) (gcc version 4.8.3 20140911 (Red Hat 4.8.3-9) (GCC) ) #1 SMP Thu Nov 19 22:10:57 UTC 2015
m4 (GNU M4) 1.4.16
GNU Make 3.82
GNU patch 2.7.1
Perl version='5.16.3';
sed (GNU sed) 4.2.2
tar (GNU tar) 1.26
makeinfo (GNU texinfo) 5.1
xz (XZ Utils) 5.1.2alpha
g++ compilation OK

My ~/.bashrc of the LSF User:

set +h
umask 022
LFS=/mnt/lfs
LC_ALL=POSIX
LFS_TGT=$(uname -m)-lfs-linux-gnu
PATH=/tools/bin:/bin:/usr/bin
export LFS LC_ALL LFS_TGT PATH

My ~/.bash_profile of the LFS User

exec env -i HOME=$HOME TERM=$TERM PS1='\u:\w\$ ' /bin/bash

Thanks for your help!


Solution

  • This error occurs when you've not installed the Binutils package properly. ld is provided by the binutils pacakage.

    Please adhere to the steps provided in the book becuase if you deviate even a little it'll cause such errors.