Chinaunix首页 | 论坛 | 博客
  • 博客访问: 381581
  • 博文数量: 83
  • 博客积分: 1650
  • 博客等级: 上尉
  • 技术积分: 861
  • 用 户 组: 普通用户
  • 注册时间: 2010-10-18 18:22
文章分类
文章存档

2021年(1)

2016年(1)

2015年(2)

2014年(3)

2013年(12)

2012年(16)

2011年(18)

2010年(30)

分类:

2012-06-30 15:10:34

2 编译busybox

2.1 Makefile中添加编译工具:
#vim Makefile
找到OSS_COMPILE ?=
修改为:CROSS_COMPILE=/usr/local/arm/3.4.1/bin/arm-linux-
也可以运行make menuconfig,进入配置接口来配置,这样做的前提是必须在$PATH中已添加了交叉编译gcc
#make menuconfig
进入“Busybox Settings ——>”
“Build options ---->”
选择( ) Cross Compiler prefix 输入arm-linux-

2.2 使用默认配置进行编译
#make defconfig
会有一些默认的选项配置,同时需要修改以下选项,以避免出现一些错误:
 ·  Busybox Settings ---> 
·       Build Options ---> 
·            [*] Build BusyBox as a static binary (no shared libs) //这里编译为静态库 
·            [ ] Build with Large File Support //这里要去掉这一项 
·            () Cross Compiler perfix //设置交叉编译器路径 
·       Installation Options ---> 
·            [*] Don't use /usr //不安装到系统的usr目录下,以解压目录下的_install来代替
·  Linux System Utilities ---> 
·       [ ] mkfs_ext2 
·       [ ] mkfs_vfat  //这两项不选,否则编译会报错


然后make,
通常会有一些错误,我们的目标是先通过编译。所以对下面几个错误采用最简便的办法处理通过。

#make
miscutils/ionice.c: In function `ioprio_set':
miscutils/ionice.c:16: error: `SYS_ioprio_set' undeclared (first use in this function)
miscutils/ionice.c:16: error: (Each undeclared identifier is reported only once
miscutils/ionice.c:16: error: for each function it appears in.)
miscutils/ionice.c: In function `ioprio_get':
miscutils/ionice.c:21: error: `SYS_ioprio_get' undeclared (first use in this function)
make[1]: *** [miscutils/ionice.o] Error 1
make: *** [miscutils] Error 2

将引起错误的功能去掉,这个ionice的位置:
Miscellaneous Utilities  --->    
[ * ] ionice                                    

重新make ,出现第2次make 错误:
#make
networking/interface.c:807: error: `ARPHRD_INFINIBAND' undeclared here (not in a function)
networking/interface.c:807: error: initializer element is not constant
networking/interface.c:807: error: (near initialization for `ib_hwtype.type')
make[1]: *** [networking/interface.o] Error 1
make: *** [networking] Error 2
在出错位置看一下源码,发现:
#if ENABLE_FEATURE_HWIB
……
由于跟infiniband 没啥关系,不如关闭这个:ENABLE_FEATURE_HWIB
在.config 中直接关掉,或者到make menuconfig中关掉:
Busybox Settings--->
Busybox Library Tuning-->
[]Support infiniband HW


第3次make错误:
#make
networking/libiproute/ipaddress.c: In function `print_linkinfo':
networking/libiproute/ipaddress.c:167: error: `IFLA_OPERSTATE' undeclared (first use in this function)
networking/libiproute/ipaddress.c:167: error: (Each undeclared identifier is reported only once
networking/libiproute/ipaddress.c:167: error: for each function it appears in.)
make[1]: *** [networking/libiproute/ipaddress.o] Error 1
make: *** [networking/libiproute] Error 2

找到源码位置,
我们对代码做如下修改:networking/libiproute/ipaddress.c
         printf("master %s ", ll_idx_n2a(*(int*)RTA_DATA(tb[IFLA_MAST    ER]), b1));
165         }
166 #endif
//在这里添加宏判断:
#ifdef IFLA_OPERSTATE  

167         if (tb[IFLA_OPERSTATE]) {
168                 static const char operstate_labels[] ALIGN1 =
169                         "UNKNOWN\0""NOTPRESENT\0""DOWN\0""LOWERLAYERDOWN\0"
170                         "TESTING\0""DORMANT\0""UP\0";
171                 printf("state %s ", nth_string(operstate_labels,
172                                         *(uint8_t *)RTA_DATA(tb[IFLA_OPERSTA    TE])));
173         }
#endif //这里添加宏结束
174if (G_filter.showqueue)

第4次编译,成功:
CC      util-linux/volume_id/romfs.o
  CC      util-linux/volume_id/sysv.o
  CC      util-linux/volume_id/udf.o
  CC      util-linux/volume_id/util.o
  CC      util-linux/volume_id/volume_id.o
  CC      util-linux/volume_id/xfs.o
  AR      util-linux/volume_id/lib.a
  LINK    busybox_unstripped
Trying libraries: crypt m
 Library crypt is not needed, excluding it
 Library m is needed, can't exclude it (yet)
Final link with: m
  DOC     busybox.pod
  DOC     BusyBox.txt
  DOC     BusyBox.1
  DOC     BusyBox.html

附:
如果Linux System Utilities ---> 
·       [*] mkfs_ext2 
·       [ *] mkfs_vfat  //如果这两项选上,编译会报错如下:

In file included from /usr/local/arm/3.4.1/lib/gcc/arm-linux/3.4.1/../../../../arm-linux/sys-include/linux/cache.h:4,
                 from /usr/local/arm/3.4.1/lib/gcc/arm-linux/3.4.1/../../../../arm-linux/sys-include/linux/fs.h:18,
                 from util-linux/mkfs_ext2.c:11:
/usr/local/arm/3.4.1/lib/gcc/arm-linux/3.4.1/../.

2.3 生成根文件系统必需文件:
#make install
会在当前busybox 目录下生成_install子目录,目录下生成bin, sbin, usr三个子目录,并且生成linuxrc文件
阅读(3722) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~