arm: ./busybox: line 1: syntax error: unexpected word (expecting ")")

arm: ./busybox: line 1: syntax error: unexpected word (expecting ")")

我正在设置一个专门用于armv7l 交叉编译的虚拟机。作为测试,我决定编译 busybox,虽然交叉编译本身工作正常,但在将生成的二进制文件上传到具有正确架构的路由器时,二进制文件抱怨 ./busybox: line 1: syntax error: unexpected word (expecting ")")

我在为 x86 编译时没有遇到这个问题,因此我认为问题出在我的构建环境上。

它基于 ubuntu18 服务器,我已经安装了这些软件包:

gcc-arm-linux-gnueabi
binutils-arm-linux-gnueabi
libncurses5-dev
gawk
build-essentials
make

我的构建脚本:

export ac_cv_linux_vers=2
export CC=/usr/local/arm-2011.09/bin/arm-none-linux-gnueabi-gcc
export GCC=/usr/local/arm-2011.09/bin/arm-none-linux-gnueabi-gcc
export CXX=/usr/local/arm-2011.09/bin/arm-none-linux-gnueabi-g++
export CPP=/usr/local/arm-2011.09/bin/arm-none-linux-gnueabi-cpp
export LD=/usr/local/arm-2011.09/bin/arm-none-linux-gnueabi-ld
export AR=/usr/local/arm-2011.09/bin/arm-none-linux-gnueabi-ar
export AS=/usr/local/arm-2011.09/bin/arm-none-linux-gnueabi-as
export NM=/usr/local/arm-2011.09/bin/arm-none-linux-gnueabi-nm
export RANLIB=/usr/local/arm-2011.09/arm-none-linux-gnueabi/bin/ranlib
export CC1=/usr/local/arm-2011.09/libexec/gcc/arm-none-linux-gnueabi/4.6.1/cc1
export PATH=/usr/local/arm-2011.09/bin:/usr/local/arm-2011.09/:/usr/local/arm-2011.09/lib:/usr/local/arm-2011.09/libexec/gcc/arm-none-linux-gnueabi/4.6.1:$PATH
export ac_cv_func_getpgrp_void=yes
export ac_cv_func_setpgrp_void=yes
export LDFLAGS="-static"
export CFLAGS="-Os -s"
# I already did make ARCH=arm CROSS_COMPILE=arm-linux-gnueabi- 
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabi-
make install

我的构建过程有任何明显的缺陷吗?


我尝试 运行 busybox 的平台:

# cat /proc/cpuinfo
processor   : 0
model name  : ARMv7 Processor rev 1 (v7l)
BogoMIPS    : 1594.16
Features    : swp half thumb fastmult edsp thumbee tls 
CPU implementer : 0x41
CPU architecture: 7
CPU variant : 0x4
CPU part    : 0xc09
CPU revision    : 1
CPU physical    :0

processor   : 1
model name  : ARMv7 Processor rev 1 (v7l)
BogoMIPS    : 1594.16
Features    : swp half thumb fastmult edsp thumbee tls 
CPU implementer : 0x41
CPU architecture: 7
CPU variant : 0x4
CPU part    : 0xc09
CPU revision    : 1
CPU physical    :1

Hardware    : Hisilicon A9
Revision    : 0000
Serial      : 0000000000000000

# uname -m
armv7l

解决了。原来我的make menuconfig不完整

Busybox Settings -> Build Options -> Build Busybox as a static binary (no shared libs)
Busybox Settings -> Build Options -> Cross compiler prefix -> Set this option equal to "arm-linux-gnueabi-"
Busybox Settings -> Installation Options -> Don't use /usr -> Enable
Linux Module Utilities -> () Default directory containing modules -> blank

之后,构建脚本生成的二进制文件按预期运行