I was trying to install rvm using \curl -L https://get.rvm.io | bash -s stable --ruby --autolibs=enable --auto-dotfiles. It worked fine until I got a configure error:

Error running './configure --prefix=/home/nishant/.rvm/rubies/ruby-2.0.0-p247 --disable-install-doc --enable-shared',
please read /home/nishant/.rvm/log/1379591052_ruby-2.0.0-p247/configure.log
There has been an error while running configure. Halting the installation.

Following are the contents of the mentioned log file:

[2013-09-19 17:15:58] ./configure
current path: /home/nishant/.rvm/src/ruby-2.0.0-p247
command(4): ./configure --prefix=/home/nishant/.rvm/rubies/ruby-2.0.0-p247 --disable-install-doc --enable-shared
checking build system type... i686-pc-linux-gnu
checking host system type... i686-pc-linux-gnu
checking target system type... i686-pc-linux-gnu
checking for gcc... gcc
checking whether the C compiler works... no
configure: error: in `/home/nishant/.rvm/src/ruby-2.0.0-p247':
configure: error: C compiler cannot create executables
See `config.log' for more details

I then tried a "hello world" C program and got the following error on compilation:

nishant@nishant-Inspiron-1545:~$ gcc -g -o hello hello.c 
/usr/local/bin/ld: this linker was not configured to use sysroots
collect2: error: ld returned 1 exit status

I'm not sure why this error is thrown. I couldn't find a satisfactory answer to this on the forum. Could someone please help. Thanks

  • 1
    I got this error when I mistakenly specified CXXFLAGS for CPPFLAGS when running the './configure' script. So the error message doesn't explain the exact error. Dec 5, 2013 at 16:31

3 Answers 3


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.

  • 9
    Normally /usr/local/bin is ahead of /usr/bin in PATH for good reason: there's no point in having a program installed locally if the version from the distribution takes precedence. Good job spotting the problem, but the recommended resolution is not to change the PATH but to either remove or fix that broken /usr/local/bin/ld. Sep 19, 2013 at 12:40
  • @steeldriver : If it not there in ~/.bashrc could I just copy-paste the line "export PATH="/usr/bin:$PATH"" there. Or would it create a problem for other programs?
    – naka
    Sep 19, 2013 at 12:50
  • @Gilles I have edited my answer to reflect your comment @naka I advise against that, it will cause more confusion in the long run - you should take note of Gilles' comment and find out why your admin has set up the PATH to use the version in /usr/local Sep 19, 2013 at 12:57
  • 3
    I got the same error … this did not work for me … which ld returns only /usr/bin/ld …. Oct 22, 2014 at 4:21

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++

Try to update system, reinstall the packages providing ld and the compiler (gcc). Run prelink -au && depmod -a. Then reboot.

You may need to disable or reconfigure prelink in /etc/systemctl or wherever your distros sets this up.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .