configure: error: C compiler cannot create executables

Solution 1:

It looks like you have a non-standard version of the GNU linker ld in your /usr/local/bin directory (possibly installed from source), and your PATH environment variable is set such that the system finds that version before the 'system' version (which should be at /usr/bin/ld). If you want to build using the standard system versions of the build tools, you will need to adjust your PATH environment variable so that it searches /usr/bin ahead of /usr/local/bin

If you want to permanently fix your PATH variable, you will need to find out where you set it originally - probably in your ~/.bashrc file, but other locations are possible. Alternatively, if you just need a temporary fix for this build, you could try

export PATH="/usr/bin:$PATH"

in the terminal before executing the ./configure

However there are sometimes good reasons why you (or your system admin) may want you to use versions of tools from /usr/local - if so, then you will need to find out why the ld there is apparently not compatible with the rest of the build chain and fix it - if this is a work or school system then contact your system administrator or IT department.

Solution 2:

Contrary to the complicated reasons given above, in my case, it was simply a case of not having g++ installed. Oddly, the error message was the same as described by the OP i.e

configure: error: C compiler cannot create executables

Anyways, I resolved this by installing g++:

sudo apt-get install g++