环境
虚拟机:ubuntu18
准备工作
查看固件中busybox版本号
下载对应版本的busybox
https://busybox.net/downloads/
安装依赖文件
sudo apt-get install zlib1g-dev unzip gcc g++ aptitude lib32stdc++6-4.8-dbg make build-essential libncurses5 libncurses5-dev u-boot-tools traceroute sudo gcc-arm-linux-gnueabihf g++-arm-linux-gnueabihf -y
编译busybox
- 终端进入到下载解包后的busybox目录
- 执行命令:make defconfig //将根据当前系统的配置生成默认的BusyBox配置文件
根据需求,可以使用命令来扩展自定义 BusyBox 的功能选项:make menuconfig
Build Options->Build BusyBox as a static binary (no shared libs)
//这个选项是一定要选择的,这样才能把busybox编译成静态链接的可执行文件,运行时才独立于其他函数库.否则必需要其他库文件才能运行,在单一个 linux内核不能使他正常工作.Busybox Settings ---> Debugging Options ---> [*] Build BusyBox with extra Debugging symbols //将BusyBox构建为带有附加调试符号
执行 make 前更改下面两个文件
Makefile:164行改为 CROSS_COMPILE :=arm-linux-gnueabihf- //添加编译器
include/libbb.h:添加引用 #include <sys/resource.h>
执行命令:make //编译过程可能需要一些时间
执行命令:make install //将生成 _install 文件
生成的 _install 目录下会有 bin、dev、sbin、usr 这四个目录以及 linuxrc 程序文件