环境:fedora 7
编译器: 交叉编译器 3.3.2
busybox: 1.4.2
一 修改
修改busybox中的 Makefile文件
找到 ARCH 和 CROSS_COMPILE 修改成如下
ARCH ?= arm
CROSS_COMPILE ?= /usr/local/arm/3.3.2/bin/arm-linux-
二 配置
[root@localhost busybox-1.4.2]# make defconfig
[root@localhost busybox-1.4.2]# make xconfig
修改配置 主要修改如下
Busybox Settings
Build Options
[ ]Build BusyBox as a static binary
//此选项选了就会出错。所以只能动态编译。
Miscellaneous Utilities
[]readahead //如果上面去掉了Busybox Settings---> Build Options---->[ ]Build with Large File Support
//该选项就不会出现。
[]taskset //选了就会出错
Linux Module Utilities
[*]Support version 2.2.x to 2.4.x Linux kernels
Shells
Choose your default shell
选 ash
三 编译
[root@localhost busybox-1.4.2]# make all install
[root@localhost busybox-1.4.2]# cd _install/bin/
[root@localhost bin]# pwd
/root/maoyong/busybox-1.4.2/_install/bin
[root@localhost bin]# ls
addgroup catv cpio dmesg fdflush hostname iprule login more nice ps sed su uname
adduser chattr date dumpkmap fgrep ip iptunnel ls mount pidof pwd setarch sync uncompress
ash chgrp dd echo getopt ipaddr kill lsattr mountpoint ping rm sh tar usleep
bbconfig chmod delgroup ed grep ipcalc linux32 mkdir mt ping6 rmdir sleep touch vi
busybox chown deluser egrep gunzip iplink linux64 mknod mv pipe_progress rpm stat true watch
cat cp df false gzip iproute ln mktemp netstat printenv run-parts stty umount zcat
[root@localhost bin]# file busybox
busybox: ELF 32-bit LSB executable, ARM, version 1, dynamically linked (uses shared libs), for GNU/Linux 2.0.0, stripped
四 查看共享了哪些库文件
用命令 arm-linux-readelf -a ${PROGRAM} | grep "Shared library"
[root@localhost bin]# pwd
/root/maoyong/busybox-1.4.2/_install/bin
[root@localhost bin]# arm-linux-readelf -a busybox | grep "Shared library"
0x00000001 (NEEDED) Shared library: [libcrypt.so.1]
0x00000001 (NEEDED) Shared library: [libm.so.6]
0x00000001 (NEEDED) Shared library: [libc.so.6]
如上所示 要把 /usr/local/arm/3.3.2/arm-linux/lib目录下的
libcrypt.so.1
libm.so.6
libc.so.6
文件是busybox所需的共享库文件,要把它以及和他相关的链接文件拷贝到
你新建的文件系统的 lib 目录。
(注意: libcrypt.so.1 libm.so.6 libc.so.6相关的链接文件也要拷贝到lib目录)
环境:fedora 7
编译器: 交叉编译器 3.3.2
busybox: 1.5.1
(busy1.5.1 可以静态编译,不会出错 :))
一 修改
修改busybox中的 Makefile文件
找到 ARCH 和 CROSS_COMPILE 修改成如下
ARCH ?= arm
CROSS_COMPILE ?= /usr/local/arm/3.3.2/bin/arm-linux-
二 配置
[root@localhost busybox-1.5.1]# make defconfig
[root@localhost busybox-1.5.1]# make xconfig
修改配置 主要修改如下
Busybox Settings
Build Options
[*]Build BusyBox as a static binary
//选此项静态编译。
Miscellaneous Utilities
[]taskset //选了就会出错
其他的和1.4.2 操作相同。
[root@localhost busybox-1.5.1]# make all install
最后会在 busybox-1.5.1/_install/目录生成你要的 bin sbin usr 目录
[root@localhost busybox-1.5.1]# cd _install/
[root@localhost _install]# ls
bin linuxrc sbin usr
[root@localhost busybox-1.5.1]# cd _install/
[root@localhost _install]# ls
bin linuxrc sbin us
[root@localhost _install]# cd bin
[root@localhost bin]# ls
addgroup chattr date dumpkmap fgrep ip iptunnel ls mount pidof pwd setarch sync uncompress
adduser chgrp dd echo getopt ipaddr kill lsattr mountpoint ping rm sh tar usleep
ash chmod delgroup ed grep ipcalc linux32 mkdir mt ping6 rmdir sleep touch vi
busybox chown deluser egrep gunzip iplink linux64 mknod mv pipe_progress rpm stat true watch
cat cp df false gzip iproute ln mktemp netstat printenv run-parts stty umount zcat
catv cpio dmesg fdflush hostname iprule login more nice ps sed su uname
[root@localhost bin]# file busybox
busybox: ELF 32-bit LSB executable, ARM, version 1, statically linked, stripped
(此处没有和busybox1.4.2输出信息,是因为是静态编译的,不需要用到库了
[root@localhost bin]# arm-linux-readelf -a busybox | grep "Shared library"
[root@localhost bin]#