configure: error: cannot run /bin/bash config/config.sub 解决configure配置问题

本文详细介绍了在Linux环境下,使用./configure命令时可能遇到的错误及其解决方案,特别针对joy工具安装过程中出现的问题,包括缺少依赖包和版本变量不一致等。通过具体的步骤,如检查并替换config.sub和config.guess文件,帮助读者成功解决配置错误。

linux下./configure 后可能会出现各种问题,缺少依赖包,或者版本 变量不一致等。不同的行为可能会产生同一错误,我是在安装 joy 工具时,遇到该报错。下面的方法不一定对你的问题一定有用,这就是个尝试的过程,只要能解决问题就好。
若你也是在安装 joy,可参考文章
操作环境:Ubuntu 16.04

问题描述

root@ubuntu:/home/joy# ./configure --enable-gzip
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
/home/joy/config/missing: line 3: $'\r': command not found
......
checking for ranlib... ranlib
configure: error: cannot run /bin/bash config/config.sub
  1. 确保已经安装下列工具
yum install libtool       
yum install libtool-ltdl    
yum install libtool-ltdl-devel 
  1. 在终端运行如下命令,查看报错处
root@ubuntu:/home/joy# /bin/bash config/config.sub
config/config.sub: line 4: $'\r': command not found
config/config.sub: line 6: $'\r': command not found
config/config.sub: line 26: $'\r': command not found
config/config.sub: line 27: $'\r': command not found
config/config.sub: line 34: $'\r': command not found
config/config.sub: line 37: $'\r': command not found
config/config.sub: line 45: $'\r': command not found
config/config.sub: line 52: $'\r': command not found
config/config.sub: line 54: $'\r': command not found
config/config.sub: line 67: $'\r': command not found
config/config.sub: line 75: $'\r': command not found
config/config.sub: line 78: $'\r': command not found
config/config.sub: line 81: syntax error near unexpected token `$'in\r''
'onfig/config.sub: line 81: `  case $1 in

  1. 找道系统中所有的 config.sub 文件,与自己目录下的进行比较
root@ubuntu:~# find / -name config.sub
/home/joy/config/config.sub
/usr/share/libtool/build-aux/config.sub
/usr/share/misc/config.sub
/mnt/hgfs/CDH-Hadoop/joy/config/config.sub

  1. 错误解决

用系统中的config.sub 文件替换

mv /home/joy/config/config.sub /home/joy/config/config.sub.bak
cp /usr/share/libtool/build-aux/config.sub /home/joy/config/config.sub

mv /home/joy/config/config.guess /home/joy/config/config.guess.bak
cp /usr/share/libtool/build-aux/config.guess /home/joy/config/config.guess
  1. 进行测试 报错消除
root@ubuntu:/home/joy# ./configure --enable-gzip
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
/home/joy/config/missing: line 3: $'\r': command not found
/home/joy/config/missing: line 5: $'\r': command not found
......
checking for zlib.h... yes
checking for zlib.h... (cached) yes
configure: creating ./config.status
config.status: creating Makefile
config.status: creating safe_c_stub/Makefile
config.status: creating safe_c_stub/lib/Makefile
config.status: creating lib/Makefile
config.status: creating bin/Makefile
config.status: creating joy_config.h
config.status: executing depfiles commands
config.status: executing libtool commands

该文章大量参考 https://stackoverflow.com/questions/24168165/configure-error-cannot-run-bin-sh

bell@bell-virtual-machine:~/nm/openwrt-15.05.1$ make V=s -j4 make[1]: Entering directory '/home/bell/nm/openwrt-15.05.1' make[2]: Entering directory '/home/bell/nm/openwrt-15.05.1' make[2]: Entering directory '/home/bell/nm/openwrt-15.05.1' + mkdir -p /home/bell/nm/openwrt-15.05.1/staging_dir/target-arm_mpcore+vfp_uClibc-0.9.33.2_eabi + mkdir -p /home/bell/nm/openwrt-15.05.1/staging_dir/host + cd /home/bell/nm/openwrt-15.05.1/staging_dir/target-arm_mpcore+vfp_uClibc-0.9.33.2_eabi + mkdir -p bin lib include stamp + cd /home/bell/nm/openwrt-15.05.1/staging_dir/host + mkdir -p bin lib include stamp mkdir -p /home/bell/nm/openwrt-15.05.1/build_dir/target-arm_mpcore+vfp_uClibc-0.9.33.2_eabi/stamp mkdir -p /home/bell/nm/openwrt-15.05.1/build_dir/host/stamp /home/bell/nm/openwrt-15.05.1/staging_dir/host/include/sys touch /home/bell/nm/openwrt-15.05.1/staging_dir/target-arm_mpcore+vfp_uClibc-0.9.33.2_eabi/.prepared install -m0644 /home/bell/nm/openwrt-15.05.1/tools/include/*.h /home/bell/nm/openwrt-15.05.1/staging_dir/host/include/ install -m0644 /home/bell/nm/openwrt-15.05.1/tools/include/sys/*.h /home/bell/nm/openwrt-15.05.1/staging_dir/host/include/sys/ ln -sf lib /home/bell/nm/openwrt-15.05.1/staging_dir/host/lib64 touch /home/bell/nm/openwrt-15.05.1/staging_dir/host/.prepared make[3]: Entering directory '/home/bell/nm/openwrt-15.05.1/tools/patch' make[3]: Entering directory '/home/bell/nm/openwrt-15.05.1/tools/make-ext4fs' make[3]: Entering directory '/home/bell/nm/openwrt-15.05.1/tools/sstrip' rm -rf /home/bell/nm/openwrt-15.05.1/staging_dir/target-arm_mpcore+vfp_uClibc-0.9.33.2_eabi/root-realview make[2]: Leaving directory '/home/bell/nm/openwrt-15.05.1' make[3]: Entering directory '/home/bell/nm/openwrt-15.05.1/tools/firmware-utils' gcc -O2 -I/home/bell/nm/openwrt-15.05.1/staging_dir/host/include -I/home/bell/nm/openwrt-15.05.1/staging_dir/host/usr/include -include endian.h -o /home/bell/nm/openwrt-15.05.1/build_dir/host/sstrip/sstrip src/sstrip.c gcc: error trying to exec 'cc1': execvp: No such file or directory Makefile:25: recipe for target '/home/bell/nm/openwrt-15.05.1/build_dir/host/sstrip/.built' failed make[3]: *** [/home/bell/nm/openwrt-15.05.1/build_dir/host/sstrip/.built] Error 1 make[3]: Leaving directory '/home/bell/nm/openwrt-15.05.1/tools/sstrip' tools/Makefile:122: recipe for target 'tools/sstrip/compile' failed make[2]: *** [tools/sstrip/compile] Error 2 make[2]: *** Waiting for unfinished jobs.... (cd /home/bell/nm/openwrt-15.05.1/build_dir/host/patch-2.7.5/; if [ -x configure ]; then cp -fpR /home/bell/nm/openwrt-15.05.1/scripts/config.{guess,sub} /home/bell/nm/openwrt-15.05.1/build_dir/host/patch-2.7.5// && bash ./configure CC="gcc" CFLAGS="-O2 -I/home/bell/nm/openwrt-15.05.1/staging_dir/host/include -I/home/bell/nm/openwrt-15.05.1/staging_dir/host/usr/include" CPPFLAGS="-I/home/bell/nm/openwrt-15.05.1/staging_dir/host/include -I/home/bell/nm/openwrt-15.05.1/staging_dir/host/usr/include" LDFLAGS="-L/home/bell/nm/openwrt-15.05.1/staging_dir/host/lib -L/home/bell/nm/openwrt-15.05.1/staging_dir/host/usr/lib" SHELL="/usr/bin/env bash" --target=x86_64-linux-gnu --host=x86_64-linux-gnu --build=x86_64-linux-gnu --program-prefix="" --program-suffix="" --prefix=/home/bell/nm/openwrt-15.05.1/staging_dir/host --exec-prefix=/home/bell/nm/openwrt-15.05.1/staging_dir/host --sysconfdir=/home/bell/nm/openwrt-15.05.1/staging_dir/host/etc --localstatedir=/home/bell/nm/openwrt-15.05.1/staging_dir/host/var --sbindir=/home/bell/nm/openwrt-15.05.1/staging_dir/host/bin ; fi ) make[3]: Leaving directory '/home/bell/nm/openwrt-15.05.1/tools/make-ext4fs' mkdir -p /home/bell/nm/openwrt-15.05.1/build_dir/host/firmware-utils/bin gcc -O2 -I/home/bell/nm/openwrt-15.05.1/staging_dir/host/include -I/home/bell/nm/openwrt-15.05.1/staging_dir/host/usr/include -include endian.h -L/home/bell/nm/openwrt-15.05.1/staging_dir/host/lib -L/home/bell/nm/openwrt-15.05.1/staging_dir/host/usr/lib -o /home/bell/nm/openwrt-15.05.1/build_dir/host/firmware-utils/bin/addpattern src/addpattern.c gcc: error trying to exec 'cc1': execvp: No such file or directory Makefile:82: recipe for target '/home/bell/nm/openwrt-15.05.1/build_dir/host/firmware-utils/.built' failed make[3]: *** [/home/bell/nm/openwrt-15.05.1/build_dir/host/firmware-utils/.built] Error 1 make[3]: Leaving directory '/home/bell/nm/openwrt-15.05.1/tools/firmware-utils' tools/Makefile:122: recipe for target 'tools/firmware-utils/compile' failed make[2]: *** [tools/firmware-utils/compile] Error 2 checking for a BSD-compatible install... /usr/bin/install -c checking whether build environment is sane... yes checking for a thread-safe mkdir -p... /bin/mkdir -p checking for gawk... gawk checking whether make sets $(MAKE)... yes checking whether make supports nested variables... yes checking whether make supports nested variables... (cached) yes checking for x86_64-linux-gnu-gcc... gcc checking whether the C compiler works... no configure: error: in `/home/bell/nm/openwrt-15.05.1/build_dir/host/patch-2.7.5': configure: error: C compiler cannot create executables See `config.log' for more details Makefile:21: recipe for target '/home/bell/nm/openwrt-15.05.1/build_dir/host/patch-2.7.5/.configured' failed make[3]: *** [/home/bell/nm/openwrt-15.05.1/build_dir/host/patch-2.7.5/.configured] Error 77 make[3]: Leaving directory '/home/bell/nm/openwrt-15.05.1/tools/patch' tools/Makefile:122: recipe for target 'tools/patch/compile' failed make[2]: *** [tools/patch/compile] Error 2 make[2]: Leaving directory '/home/bell/nm/openwrt-15.05.1' tools/Makefile:121: recipe for target '/home/bell/nm/openwrt-15.05.1/staging_dir/target-arm_mpcore+vfp_uClibc-0.9.33.2_eabi/stamp/.tools_install_yynyynynynyyyyyyyyynyyyyyyyyynyyyyynnyyynnyynnnyy' failed make[1]: *** [/home/bell/nm/openwrt-15.05.1/staging_dir/target-arm_mpcore+vfp_uClibc-0.9.33.2_eabi/stamp/.tools_install_yynyynynynyyyyyyyyynyyyyyyyyynyyyyynnyyynnyynnnyy] Error 2 make[1]: Leaving directory '/home/bell/nm/openwrt-15.05.1' Build failed - please re-run with -j1 to see the real error message /home/bell/nm/openwrt-15.05.1/include/toplevel.mk:181: recipe for target 'world' failed make: *** [world] Error 1 编译openwrt报错
最新发布
08-07
评论 7
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值