skip to Main Content

I want to cross-compile LFS on CentOS v. 7.6.1810 with no sudo rights (I want to customize my environment on server). One problem is that globally a lot of packages are outdated (for instance, python 2.7, gcc 4.8.5, gmake 3.82).

In this setting I started from the 4-th chapter of LFS and changed everywhere PATH from /tools to /path/to/my/folder/tools (I believe I did it accurately enough). It all went well until chapter 5.7. First, Glibc wanted to have newer python and gmake.
Therefore I followed 5.27.1 and 5.30.1 chapters.

After this, everything compiles well, and I was stopped on the sanity check step. I executed it from the sources/glibc/build folder, and got an error:

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

/path/to/my/folder/tools/lib/gcc/x86_64-lfs-linux-gnu/8.2.0/../../../../x86_64-lfs-linux-gnu/bin/ld: cannot find crt1.o: No such file or directory
/path/to/my/folder/tools/lib/gcc/x86_64-lfs-linux-gnu/8.2.0/../../../../x86_64-lfs-linux-gnu/bin/ld: cannot find crti.o: No such file or directory
/path/to/my/folder/tools/lib/gcc/x86_64-lfs-linux-gnu/8.2.0/../../../../x86_64-lfs-linux-gnu/bin/ld: cannot find /path/to/my/folder/tools/lib/libc.so.6 inside /path/to/my/folder
/path/to/my/folder/tools/lib/gcc/x86_64-lfs-linux-gnu/8.2.0/../../../../x86_64-lfs-linux-gnu/bin/ld: cannot find /path/to/my/folder/tools/lib/libc_nonshared.a inside /path/to/my/folder
/path/to/my/folder/tools/lib/gcc/x86_64-lfs-linux-gnu/8.2.0/../../../../x86_64-lfs-linux-gnu/bin/ld: cannot find /path/to/my/folder/tools/lib/ld-linux-x86-64.so.2 inside /path/to/my/folder
collect2: error: ld returned 1 exit status

I checked /path/to/my/folder/tools/lib/, and all wanted files (crt1.o, crti.o, libc.so.6, libc_nonshared.a, ld-linux-x86-64.so.2) are there.

I tried providing symbolic links to files and it worked for crt1.o and crti.o but not for the others.

> ln -s /path/to/my/folder/tools/lib/crt1.o crt1.o
> ln -s /path/to/my/folder/tools/lib/crti.o crti.o
> ln -s /path/to/my/folder/tools/lib/libc_nonshared.a libc_nonshared.a

/path/to/my/folder/tools/lib/gcc/x86_64-lfs-linux-gnu/8.2.0/../../../../x86_64-lfs-linux-gnu/bin/ld: cannot find /path/to/my/folder/tools/lib/libc.so.6 inside /path/to/my/folder
/path/to/my/folder/tools/lib/gcc/x86_64-lfs-linux-gnu/8.2.0/../../../../x86_64-lfs-linux-gnu/bin/ld: cannot find /path/to/my/folder/tools/lib/libc_nonshared.a inside /path/to/my/folder
/path/to/my/folder/tools/lib/gcc/x86_64-lfs-linux-gnu/8.2.0/../../../../x86_64-lfs-linux-gnu/bin/ld: cannot find /path/to/my/folder/tools/lib/ld-linux-x86-64.so.2 inside /path/to/my/folder
collect2: error: ld returned 1 exit status

UPDATE 1 Now I reinstalled older version LFS (8.1), so that I had all prerequisites fulfilled from the start. Once again I started from the 4-th chapter and no errors rose until the notorious check. The suggestion from Tim was helpful in the way the system was not ruined, but segmentation error did not allow a.out to be created:

> echo 'int main(){}' > dummy.c
> LD_LIBRARY_PATH=/path/to/my/folder/tools/lib $LFS_TGT-gcc dummy.c
Segmentation fault (core dumped)
> readelf -l a.out | grep ': /path/to/my/folder/tools'
readelf: a.out: Error: No such file

Inspired by the similar issue LFS 7.2 glibc-2.16.0 make error and tried to change LD_LIBRARY_PATH accordingly. It does not seem to work.

> echo 'int main(){}' > dummy.c
> LD_LIBRARY_PATH=/path/to/my/folder/tools/libgcc/x86_64-lfs-linux-gnu/7.2.0 $LFS_TGT-gcc dummy.c
/path/to/my/folder/tools/lib/gcc/x86_64-lfs-linux-gnu/8.2.0/../../../../x86_64-lfs-linux-gnu/bin/ld: cannot find crt1.o: No such file or directory
/path/to/my/folder/tools/lib/gcc/x86_64-lfs-linux-gnu/8.2.0/../../../../x86_64-lfs-linux-gnu/bin/ld: cannot find crti.o: No such file or directory
/path/to/my/folder/tools/lib/gcc/x86_64-lfs-linux-gnu/8.2.0/../../../../x86_64-lfs-linux-gnu/bin/ld: cannot find /path/to/my/folder/tools/lib/libc.so.6 inside /path/to/my/folder
/path/to/my/folder/tools/lib/gcc/x86_64-lfs-linux-gnu/8.2.0/../../../../x86_64-lfs-linux-gnu/bin/ld: cannot find /path/to/my/folder/tools/lib/libc_nonshared.a inside /path/to/my/folder
/path/to/my/folder/tools/lib/gcc/x86_64-lfs-linux-gnu/8.2.0/../../../../x86_64-lfs-linux-gnu/bin/ld: cannot find /path/to/my/folder/tools/lib/ld-linux-x86-64.so.2 inside /path/to/my/folder
collect2: error: ld returned 1 exit status
> readelf -l a.out | grep ': /path/to/my/folder/tools'
readelf: a.out: Error: No such file

UPDATE 2 I once again reinstalled LFS (8.1), but this time I followed steps described in this issue. Also, I used -Xlinker --verbose solution described in the comments here to inspect ld logs. Now it seems, that maybe it cannot open the mentioned libraries. Still not working, but log seems to have changed a bit.

> LFS_TGT-gcc -Xlinker --verbose dummy.c
==================================================
attempt to open crt1.o failed
attempt to open crti.o failed
attempt to open /path/to/my/folder/tools/lib/gcc/x86_64-lfs-linux-gnu/7.2.0/crtbegin.o succeeded
/path/to/my/folder/tools/lib/gcc/x86_64-lfs-linux-gnu/7.2.0/crtbegin.o
attempt to open /tmp/ccRQA7iH.o succeeded
/tmp/ccRQA7iH.o
attempt to open /path/to/my/folder/tools/lib/gcc/x86_64-lfs-linux-gnu/7.2.0/libgcc.so failed
attempt to open /path/to/my/folder/tools/lib/gcc/x86_64-lfs-linux-gnu/7.2.0/libgcc.a succeeded
attempt to open /path/to/my/folder/tools/lib/gcc/x86_64-lfs-linux-gnu/7.2.0/libc.so failed
attempt to open /path/to/my/folder/tools/lib/gcc/x86_64-lfs-linux-gnu/7.2.0/libc.a failed
attempt to open /path/to/my/folder/tools/lib/gcc/x86_64-lfs-linux-gnu/7.2.0/../../../../x86_64-lfs-linux-gnu/lib/../lib/libc.so failed
attempt to open /path/to/my/folder/tools/lib/gcc/x86_64-lfs-linux-gnu/7.2.0/../../../../x86_64-lfs-linux-gnu/lib/../lib/libc.a failed
attempt to open /path/to/my/folder/tools/lib/gcc/x86_64-lfs-linux-gnu/7.2.0/../../../../x86_64-lfs-linux-gnu/lib/libc.so failed
attempt to open /path/to/my/folder/tools/lib/gcc/x86_64-lfs-linux-gnu/7.2.0/../../../../x86_64-lfs-linux-gnu/lib/libc.a failed
attempt to open /path/to/my/folder/path/to/my/folder/tools/x86_64-lfs-linux-gnu/lib64/libc.so failed
attempt to open /path/to/my/folder/path/to/my/folder/tools/x86_64-lfs-linux-gnu/lib64/libc.a failed
attempt to open /path/to/my/folder/tools/lib/libc.so failed
attempt to open /path/to/my/folder/tools/lib/libc.a failed
attempt to open /path/to/my/folder/path/to/my/folder/tools/x86_64-lfs-linux-gnu/lib/libc.so failed
attempt to open /path/to/my/folder/path/to/my/folder/tools/x86_64-lfs-linux-gnu/lib/libc.a failed
attempt to open /path/to/my/folder/tools/lib/gcc/x86_64-lfs-linux-gnu/7.2.0/libgcc.so failed
attempt to open /path/to/my/folder/tools/lib/gcc/x86_64-lfs-linux-gnu/7.2.0/libgcc.a succeeded
attempt to open /path/to/my/folder/tools/lib/gcc/x86_64-lfs-linux-gnu/7.2.0/crtend.o succeeded
/path/to/my/folder/tools/lib/gcc/x86_64-lfs-linux-gnu/7.2.0/crtend.o
attempt to open crtn.o failed
/path/to/my/folder/tools/lib/gcc/x86_64-lfs-linux-gnu/7.2.0/../../../../x86_64-lfs-linux-gnu/bin/ld: cannot find crt1.o: No such file or directory
/path/to/my/folder/tools/lib/gcc/x86_64-lfs-linux-gnu/7.2.0/../../../../x86_64-lfs-linux-gnu/bin/ld: cannot find crti.o: No such file or directory
/path/to/my/folder/tools/lib/gcc/x86_64-lfs-linux-gnu/7.2.0/../../../../x86_64-lfs-linux-gnu/bin/ld: cannot find -lc
/path/to/my/folder/tools/lib/gcc/x86_64-lfs-linux-gnu/7.2.0/../../../../x86_64-lfs-linux-gnu/bin/ld: cannot find crtn.o: No such file or directory
collect2: error: ld returned 1 exit status

Can you please give a suggestion, how to deal with this nasty ld problem. I know that it is not good to skip LFS steps. Unfortunately, I have no way to fix this, but I want to upgrade my local environment as much as possible. Thank you!

3

Answers


  1. This command will update LD_LIBRARY_PATH for the entire shell:

    export LD_LIBRARY_PATH=/path/to/my/folder/tools/lib
    

    you only want it updated for the one command. Try this instead:

    LD_LIBRARY_PATH=/path/to/my/folder/tools/lib $LFS_TGT-gcc dummy.c
    

    Update: So that didn’t work… how about trying this?

    $LFS_TGT-gcc -L/path/to/my/folder/tools/lib dummy.c
    
    Login or Signup to reply.
  2. I’m on a path of compiling LFS in a different directory just like you.
    I followed the same steps as you have. And have gotten the exact same results.

    But I think I have one hint, you haven’t mentioned:

    /path/to/my/folder/tools/bin/x86_64-lfs-linux-gnu-ld /path/to/my/folder/tools/lib/libc.so.6
    

    Gives warning:

    x86_64-lfs-linux-gnu-ld: warning: cannot find entry symbol _start; not setting start address

    Hope this can help uncover the problem.

    Login or Signup to reply.
  3. check version of glibc in this line --with-glibc-version=2.11 from gcc script with version of host system requirements.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search