Configure: error: cannot run /bin/sh
Asked Answered
U

3

6

I am trying to build GNU toolchain for OpenRISC by following the guide given at http://openrisc.net/toolchain-build.html on Fedora Virtual Box Image.

I am getting error saying

Configure: error: cannot run /bin/sh ../gcc-svn/config.sub

when I try to configure gcc.

I am new to Linux. I could not find any solution online. Any help to solve the issue is highly appreciated.

Upland answered 11/6, 2014 at 16:38 Comment(0)
E
10

Open config.sub with a hex editor to see if the line endings are \r\n instead of just \n. If so, make a backup of the entire folder and then type:

dos2unix *

That will change all line endings from \r\n to \n, and it does it in place, overwriting each file. Then, again try:

./configure (with any options you desire)

I had this problem on cygwin for Windows where GitHub had converted all files to \r\n, so I had to convert them back with dos2unix.

Epicanthus answered 28/10, 2016 at 1:49 Comment(3)
Or without installing dos2unix: https://mcmap.net/q/20384/-39-r-39-command-not-found-bashrc-bash_profile-duplicate sed -i 's/\r$//' filenameEmmaline
Helped me with solving my issue. Thank you very much!Quasi
helped me too. thanks very muchDomingo
L
3

1.check and install libtools

yum install libtool       
yum install libtool-ltdl    
yum install libtool-ltdl-devel       

2.try run "../gcc-svn/config.sub" through shell

/bin/bash ../gcc-svn/config.sub

see if shows as follows:

[root@centos jemalloc]# /bin/bash ./config.sub
: command not foundine 6:
: command not foundine 8:
: command not foundine 30:
: command not foundine 31:
: command not foundine 39:
: command not foundine 42:
: command not foundine 50:
: command not foundine 57:
: command not foundine 59:
: command not foundine 72:
: command not foundine 82:
: command not foundine 85:
'/config.sub.bak: line 88: syntax error near unexpected token in
'/config.sub.bak: line 88: ` case $1 in

3.find the system config.sub

 find / -name config.sub

it shows:

/usr/share/libtool/config/config.sub

compare the two config.sub to see if they are similar.

4.replace config.sub with system file

mv ../gcc-svn/config.sub ../gcc-svn/config.sub.bak
cp /usr/share/libtool/config/config.sub ../gcc-svn/config.sub 

mv ../gcc-svn/config.guess ../gcc-svn/config.guess.bak
cp /usr/share/libtool/config/config.guess ../gcc-svn/config.guess
  1. make to see if it works out.
Luckett answered 17/11, 2014 at 8:31 Comment(1)
I was trying to ./configure a library and the config.guess and config.sub files where way outdated. Replaced both with the ones that came with libtools and it worked like a charm. Thank you!Aton
J
1

What is the first line of your ../gcc-svn/config.sub file? I'm guessing it may have a typo. It should be

#!/bin/sh

and not

/bin/sh

If it is

#!/bin/sh

Make sure that the file /bin/sh exists and is executable

ls -l /bin/sh

Should show something like

-rwxrwxrwx 1 root root 4 Feb  3  2009 /bin/sh
Justiciary answered 11/6, 2014 at 17:21 Comment(4)
Dear me, I certainly hope it isn't world-writable! :)Snuffbox
:D oversight. on my machine it was actually "lrwxrwxrwx 1 root root 4 Feb 3 2009 /bin/sh -> bash" but I thought that was confuse since it I didn't think it was usually a link. so I quickly deleted the "l" without thinking about the rest. Good point ;)Justiciary
The first line is #!/bin/sh and ls -l /bin/sh is giving the expected output. But the problem still exists.Upland
Is the config.sub file executable?Justiciary

© 2022 - 2024 — McMap. All rights reserved.