gccglibc

gcc-14.2.0/ld cannot find -lstdc++


I am trying to build native gcc-14.2.0 from sources by this tutorial - https://gist.github.com/chponte/7f27967fc72cf61e8c158923bf126b61

I am doing it on hyper-v with OS Astra Linux with installed gcc.

When I try to build glibc with

CC=/tmp/gcc-first-stage/bin/gcc ../glibc-x.x/configure --target=$TARGET --prefix=$PREFIX --with-headers=${TARGET_PREFIX}/include --without-selinux
make all install

I get the following error:

/home/elena/gcc2/14.2.0/bin/ld: cannot find -lstdc++: No such file or directory

I had tried all, which is suggested in this article - https://hatchjs.com/usr-bin-ld-cannot-find-lstdc-no-such-file-or-directory/ , but nothing works.

Also I have tried to put libstdc++.so to /home/elena/gcc2/14.2.0/bin and this did not help me too.

What else could be the reason for this error?

UPDATE 1: libstdc++.so in my system located in /usr/lib/gcc/x86_64-linux-gnu/8/libstdc++.so

UPDATE 2: this does not help too - "/usr/bin/ld: cannot find -lstdc++: No such file or directory" on running flutter linux app

UPDATE 3:

make subdir=mathvec -C mathvec ..=../ others make subdir=support -C support ..=../ others make[2]: вход в каталог «/home/elena/Desktops/Desktop1/gcc-build-root-2/glibc-2.39/support» /tmp/gcc-first-stage/bin/gcc -Wl,-rpath-link=/home/elena/Desktops/Desktop1/gcc-build-root-2/glibc-build:/home/elena/Desktops/Desktop1/gcc-build-root-2/glibc-build/math:/home/elena/Desktops/Desktop1/gcc-build-root-2/glibc-build/elf:/home/elena/Desktops/Desktop1/gcc-build-root-2/glibc-build/dlfcn:/home/elena/Desktops/Desktop1/gcc-build-root-2/glibc-build/nss:/home/elena/Desktops/Desktop1/gcc-build-root-2/glibc-build/nis:/home/elena/Desktops/Desktop1/gcc-build-root-2/glibc-build/rt:/home/elena/Desktops/Desktop1/gcc-build-root-2/glibc-build/resolv:/home/elena/Desktops/Desktop1/gcc-build-root-2/glibc-build/mathvec:/home/elena/Desktops/Desktop1/gcc-build-root-2/glibc-build/support:/home/elena/Desktops/Desktop1/gcc-build-root-2/glibc-build/nptl -o /home/elena/Desktops/Desktop1/gcc-build-root-2/glibc-build/support/links-dso-program -pie -Wl,-z,pack-relative-relocs -Wl,-O1 -nostdlib -nostartfiles -Wl,-z,mark-plt -Wl,-z,relro /home/elena/Desktops/Desktop1/gcc-build-root-2/glibc-build/csu/Scrt1.o /home/elena/Desktops/Desktop1/gcc-build-root-2/glibc-build/csu/crti.o /tmp/gcc-first-stage/bin/gcc -Wl,-z,mark-plt --print-file-name=crtbeginS.o /home/elena/Desktops/Desktop1/gcc-build-root-2/glibc-build/support/links-dso-program.o -lstdc++ -lgcc -lgcc_s -Wl,-dynamic-linker=/home/elena/gcc2/14.2.0/lib/ld-linux-x86-64.so.2 /home/elena/Desktops/Desktop1/gcc-build-root-2/glibc-build/libc.so.6 /home/elena/Desktops/Desktop1/gcc-build-root-2/glibc-build/libc_nonshared.a -Wl,--as-needed /home/elena/Desktops/Desktop1/gcc-build-root-2/glibc-build/elf/ld.so -Wl,--no-as-needed -lgcc /tmp/gcc-first-stage/bin/gcc -Wl,-z,mark-plt --print-file-name=crtendS.o /home/elena/Desktops/Desktop1/gcc-build-root-2/glibc-build/csu/crtn.o /home/elena/gcc2/14.2.0/bin/ld: cannot find -lstdc++: Нет такого файла или каталога collect2: ошибка: выполнение ld завершилось с кодом возврата 1


Solution

  • Here are a few suggestions that may let the linker (ld) find the missing library. Try them in order. Be aware that while this may let the linker proceed, you could run into other issues later (which may or may not be related to the stdlibc++ library).

    export LIBRARY_PATH=/usr/lib/gcc/x86_64-linux-gnu/8/
    

    and then run the make command again.

    export LDFLAGS='-L/usr/lib/gcc/x86_64-linux-gnu/8/'
    

    and run make again.


    Double check that the loader can find this library for when you are running a program. It should, since it's a library installed by the system, but just in case. You can look in /etc/ld.so.conf and all the files in the related subdirectory, /etc/ld.so.conf.d. Since these should all be text files, a simple

    cat /etc/ld.so.conf /etc/ld.so.conf.d/*
    

    should be enough. See if any (non-commented, obviously) line is equal to /usr/lib/gcc/x86_64-linux-gnu/8.