编译busybox,动态链接与静态链接的选择
进入解压后的Busybox-1.10.1目录,运行make menuconfig或make gconfig进行配置。
在进行配置时有几项需要注意:
Build Options->
Build BusyBox as a static binary (no shared libs)
Force NOMMU build
Build shared libbusybox
Build with Large File Support (for accessing file>2GB)
如果选择Build BusyBox as a static binary (no shared libs)方式进行编译时,所需的库已经与程序静态地链接在一起,这些程序不需要额外的库就可以单独运行,但是自己编写的程序在文件系统上运行必须采用静态编译,否则会报诸如:bin/sh: hello :not found的错误。
静态编译如:
arm-linux-gcc –static hello.c –o hello
如果选择Build shared libbusybox方式进行编译时,要将交叉编译的动态库或符号链接复制到对应的目录中,否则程序不能运行。同时在配置时应去掉Build shared libbusybox目录下的两项:如下
Build shared libbusybox->
Producebinary for each applet,linked against libbusybox
Produceadditional busybox binary linked against libbusybox
同时去掉
Build with Large File Support (for accessing file>2GB)
否则编译会报错。
一定要勾选上如下配置:
Init Utilities—>
(*) init
(*) Supporting reading an inittab file//支技init进程读取/etc/inittab配置文件。
(*) Supporting running commands with controlling-tty//使busybox在真实的串口设备中运行命令行,不使用可能会报类似与:sh:can’t access tty:job control turned off的错误。
其它基本可按默认配置。
5. 执行
make
编译完成后执行
make install
则在Busybox-1.10.1目录下有_install这个目录,这正是我们想要的。
本文详细介绍了如何在编译Busybox时选择动态链接或静态链接,包括配置选项、编译命令及安装步骤,并强调了在文件系统上运行程序时静态编译的重要性。

2884

被折叠的 条评论
为什么被折叠?



