[Solved] Centos error: collect2: fatal error: cannot find ‘ld‘

When executing a compiled file in Linux (. /configure) with collect2: fatal error: cannot find ‘ld’, which is also preceded by gcc: error: unrecognized command line option -V and configure: error: C compiler cannot create executables. When you find that your gcc and the corresponding dependency packages are installed, you still get the error. At this point you look under /usr/bin/ to see if there is an ld. which ld is not found, but you find a file called ld.gold under /usr/bin by running ls -l |grep ld.

Solution:

Copy ld.gold under /usr/bin/ (do not delete the original file) and rename it to ld. You can also create a soft connection.

Re-execute the compilation

Problem found solved!

Brief description.

gcc compiles the source code to .o, then linker links the .o to .so or executable, linker can use ld.bfd, ld.gold or lld.

Read More: