When I try to run C and C++program I am getting
collect2: fatal error: cannot find 'ld' compilation terminated.
I have already installed GCC and G++ latest version.
In my case I had this resolved with a workaround:
On the cross-compiler bin dir I made a symlink pointing to the compiler
ld (ld -> powerpc-fsl-linux-ld).
Then in the makefile or build script I added the toolchain folder to the PATH variable
export PATH=$PATH:"toolchain-dir-absolute-path"
it worked!
Our team got the same error when building RHEL6 DTS2 via AFL. We solved this using GNU linker instead of gold linker to which CMake seems to default.
In your compiler command lines, lookout for -Wl,-fuse-ld=gold and get rid of it!
In our CMake buildsystems this worked by invoking the build scripts with additional option -DCOL_WITHOUT_GOLD.
You can install the gold linker via apt-get install binutils-gold.
For me, that still gave errors, as binutils-gold installs a /usr/bin/ld.gold, and via strace, it appears gcc wants a binary named with the full host triple, e.g. x86_64-nptl-linux-gnu-ld.gold. I had to symlink it ln -s /usr/bin/ld.gold /usr/bin/x86_64-nptl-linux-gnu-ld.gold, and then all went fine.
ln -s /usr/bin/lld-8 /usr/bin/ld.lld
Commented
Mar 13, 2020 at 0:43
For whatever reason, my /usr/bin/ld.bfd permissions did not allow read or execute for all users. chmod a+rx /usr/bin/ld.bfd fixed my problem
sudo apt-get install libc6-devand if gets installed (if it's not already installed), try compiling your C/C++ programs againgcc -print-prog-name=ld,which ldanddpkg -V binutilssay?