`
king_tt
  • 浏览: 2084521 次
  • 性别: Icon_minigender_1
  • 来自: 深圳
社区版块
存档分类
最新评论

构建根文件系统一之ubuntu12.04下安装编译BusyBox图文解说

阅读更多

下载并解压

1、下载busybox源码包,可以从http://www.busybox.net/downloads/网站下载,这里我使用的是busybox-1.7.0.tar.bz2版本,本版点此下载

2、新建一个文件夹,命名为busybox(路径依自己而定,不过要记住此路径,下面会用到),并将下载的源码包存放在此目录下,如下

3、执行命令:tar -jxvf busybox-1.7.0.tar.bz2解压缩

解压缩后的文件夹

配置

4、执行命令:cd busybox-1.20.2 进入解压后的文件夹

此时你可以在此文件夹下看到解压后的文件

5、执行命令:make menuconfig ,出现配置界面

注意,很可能会出现 fatal error: curses.h: No such file or directory

compilation terminated.这样的错误,原因是没有安装ncurses库,使用以下命令即可安装:sudo apt-get install libncurses5-dev libncursesw5-dev

6、在这里先使用默认的配置,选择< Exit>,按回车键退出,会提示你是否保存

选择<Yes>

要注意的有一点,咱们这里的默认配置中使用的是动态连接,在构造根文件系统时需要在/lib目录下放置glibc库文件。不要感觉很麻烦,先这样设置就行。我也是看着韦老师的书弄的,后面还有。

编译

7、执行命令:vim Makefile 修改根目录下的Makefile,使用交叉编译器

这里只需要修改下图175和176这两行内容,不同的版本它们的所在行可能不一样。

修改后的这两行为下图

8、执行命令:make 编译BusyBox

我里个去,竟然有错误,提示以下错误

/home/song/software/opt/FriendlyARM/toolschain/4.4.3/bin/../arm-none-linux-gnueabi//sys-root/usr/include/linux/netfilter.h:55: error: field 'in' has incomplete type
/home/song/software/opt/FriendlyARM/toolschain/4.4.3/bin/../arm-none-linux-gnueabi//sys-root/usr/include/linux/netfilter.h:56: error: field 'in6' has incomplete type
ipsvd/tcpudp.c: In function 'tcpudpsvd_main':
ipsvd/tcpudp.c:314: warning: ignoring return value of 'write', declared with attribute warn_unused_result
make[1]: *** [ipsvd/tcpudp.o] 错误 1
make: *** [ipsvd] 错误 2

 

不着急,原因就是在/Your Arm-linux-gccDirectory/../arm-none-linux-gnueabi//sys-root/usr/include/linux/netfilter.h这个头文件里少加入#include<netinet/in.h> 这一句就可以了

再次make,又有如下错误,闹心

networking/libiproute/lib.a(iptunnel.o): In function `print_tunnel':
iptunnel.c:(.text.print_tunnel+0x1ec): undefined reference to `__cpu_to_be16'
iptunnel.c:(.text.print_tunnel+0x200): undefined reference to `__cpu_to_be16'
iptunnel.c:(.text.print_tunnel+0x238): undefined reference to `__cpu_to_be16'
iptunnel.c:(.text.print_tunnel+0x24c): undefined reference to `__cpu_to_be16'
iptunnel.c:(.text.print_tunnel+0x26c): undefined reference to `__cpu_to_be16'
networking/libiproute/lib.a(iptunnel.o):iptunnel.c:(.text.print_tunnel+0x290): more undefined references to `__cpu_to_be16' follow
collect2: ld returned 1 exit status
make: *** [busybox_unstripped] 错误 1

解决方法就是在该目录下的vim networking/libiproute/iptunnel.c 文件中加入#include <asm/byteorder.h>

先执行一次make clean命令,再执行make命令,好家伙,终于没错误了。如下

安装

9、执行命令:make CONFIG_PREFIX=/YourPath install,这里YourPath是你的要将BusyBox安装的位置。我将它安装在了/home/song/nfs_root/fs_mini下,如下

make CONFIG_PREFIX=/home/song/nfs_root/fs_mini install

一切完成后,将在/home/song/nfs_root/fs_mini/目录下生成如下文件

其中linuxrc和/sbin/init的功能完全一样;其他目录下是各种命令,不过它们都是到/bin/busybox的符号连接,比如 /home/song/nfs_root/fs_mini/sbin目录下:

除 bin/busybox 外,其他文件都是到bin/busybox的符号连接。busybox是所有命令的集合体,这些符号连接文件可以直接运行。比如在开发板上,运行“ls”命令和“busybox ls”命令是一样的。

到这里busybox已经安装成功了,还不知道怎么用吧,我会再写下一篇的。

下一篇:http://blog.csdn.net/mybelief321/article/details/9896311

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics