5

I have tried to create a Linux distribution with the Linux From Scratch (LFS) website. Everything went good until step 5.7. Glibc-2.19, but when I tried:

$LFS_TGT-gcc dummy.c

I get:

/tools/lib/gcc/i686-lfs-linux-gnu/4.8.2/../../../../i686-lfs-linux-gnu/bin/ld: cannot find crt1.o: No such file or directory
/tools/lib/gcc/i686-lfs-linux-gnu/4.8.2/../../../../i686-lfs-linux-gnu/bin/ld: cannot find crti.o: No such file or directory

So I googled it for a while, and I realize that Debian changed some directory, and I searched for those files and I found them in:

/usr/libx32/

I realize from those searches that it happen with trying to compile 64 bit in 32 bit structures, and I should create virtual link of theme in:

/tools/lib/gcc/i686-lfs-linux-gnu/4.8.2/

But when I did that I got:

/tools/lib/gcc/i686-lfs-linux-gnu/4.8.2/crt1.o: file not recognized: File format not recognized

In this step I really don't know what to do next. How can I fix it?

Peter Mortensen
  • 1,029
  • 1
  • 8
  • 10
zokit
  • 141
  • 1
  • 8
  • If "I should create virtual link of theme" mean that you created a symlink to a x86_64 library where a i686 library is expected, then no, you should **never** do that. – Leiaz Sep 06 '14 at 14:02

3 Answers3

8

The correct virtual link is:

ln -s /tools/lib/crt*.o /tools/lib/gcc/i686-lfs-linux-gnu/4.8.2/
Peter Mortensen
  • 1,029
  • 1
  • 8
  • 10
zokit
  • 141
  • 1
  • 8
  • 2
    Nothing wrong with answering your own question! On the contrary, taking the time to share what you find is welcomed, appreciated and [actively encouraged!](http://meta.stackexchange.com/q/132886/203101) It would be great if you could come back tomorrow (you have to wait a few hours, I forget how many, before accepting your own answer) and accept this as the correct answer too. – terdon Sep 06 '14 at 14:13
0

It should be noted that the the command below resolves the same issue on Fedora 28 as well.

ln -s /tools/lib/crt*.o /tools/lib/gcc/i686-lfs-linux-gnu/4.8.2/
Brett Holman
  • 498
  • 2
  • 11
0

Your environment variable $LFS may be wrong.

I was also trying to build LFS and got a similar error:

/mnt/tools/bin/../lib/gcc/x86_64-lfs-linux-gnu/9.2.0/../../../../x86_64-lfs-linux-gnu/bin/ld: cannot find crt1.o: No such file or directory 
/mnt/tools/bin/../lib/gcc/x86_64-lfs-linux-gnu/9.2.0/../../../../x86_64-lfs-linux-gnu/bin/ld: cannot find crti.o: No such file or directory

I've tried the solution suggested by the other comments to link the missing files directly. While it actually made it passed the simple compilation test, I stuck in the next step building libstdc++. The config ended up with the following error:

checking for stdalign.h... no
checking for the value of EOF... configure: error: computing EOF failed

After all, I found I've accidentally changed the LFS variable to a wrong path (I was using a mounting path different from the guide and I forgot to change the LFS export in .bashrc accordingly). That is the true cause.