交叉编译器: 3.3.2 # wget -c # tar jxvf busybox-1.7.0.tar.bz2
修改源码、配置、编译 ----------------------------------------------- # cd busybox-1.7.0 # vi Makefile +176 ARCH ?= arm CROSS_COMPILE ?= /usr/local/arm/3.3.2/bin/arm-linux-
# make menuconfig Busybox Settings ---> Build Options ---> [*] Build BusyBox as a static binary (no shared libs) //(1) Installation Options ---> [*] Don't use /usr //(2)
Linux System Utilities ---> [*] mdev //(3) [*] Support /etc/mdev.conf [*] Support command execution at device addition/removal
Shells ---> Choose your default shell (msh) ---> //(4)
vi rootfs/etc/init.d/rcS --------------------------- mount -t tmpfs mdev /dev mkdir /dev/pts mount -t devpts devpts /dev/pts mount -t sysfs sysfs /sys mount -a echo /sbin/mdev > /proc/sys/kernel/hotplug mdev -s
linux-2.6.19 -- make menuconfig File systems ---> Pseudo filesystems ---> [*] sysfs file system support [*] Virtual memory file system support (former shm fs) [*] Tmpfs POSIX Access Control Lists
因为busybox主要应用于对空间要求非常严格的嵌入式系统,所以它推荐使用uclibc而不鼓励使用glibc,如果你没有安装uclibc,而且在 build Options也选择了Build BusyBox as a static binary(no shared libs),那肯定无法编译通过的,当然如果你之前build Options选择的是动态编译的话就不会有这样的问题出现了。假设你是第一种情况,我们可以这样解决:把applets/applets.c开头的几行 warning注释掉
# vi applets/applets.c /* #if ENABLE_STATIC && defined(__GLIBC__) && !defined(__UCLIBC__) #warning Static linking against glibc produces buggy executables #warning (glibc does not cope well with ld --gc-sections). #warning See sources.redhat.com/bugzilla/show_bug.cgi?id=3400 #warning Note that glibc is unsuitable for static linking anyway. #warning If you still want to do it, remove -Wl,--gc-sections #warning from top-level Makefile and remove this warning. #error Aborting compilation. #endif */
# make # make install 这时会在你的编译目录下生成一个_install的目录,里面包含了生成的所有文件和目录结构。
编译时遇到的问题(1): ----------------------------------------------- 如果busybox编译成static linking Busybox Settings ---> Build Options ---> [*] Build BusyBox as a static binary (no shared libs)
# make 将会遇到下面问题: applets/applets.c:20:2: error: #warning Static linking against glibc produces buggy executables applets/applets.c:21:2: error: #warning (glibc does not cope well with ld --gc-sections). applets/applets.c:22:2: error: #warning See sources.redhat.com/bugzilla/show_bug.cgi?id=3400 applets/applets.c:23:2: error: #warning Note that glibc is unsuitable for static linking anyway. applets/applets.c:24:2: error: #warning If you still want to do it, remove -Wl,--gc-sections applets/applets.c:25:2: error: #warning from top-level Makefile and remove this warning. make[1]: *** [applets/applets.o] Error 1