编译busybox

make[1]: *** [ipsvd/tcpudp.o] Error 1

make: *** [ipsvd] Error 2


【具体步骤】: 

     1) 下载busybox源代码,并解包 

     $ wget -c http://www.busybox.net/downloads/busybox-1.7.0.tar.bz2

     $ tar jxvf busybox-1.7.0.tar.bz2 

  

     2) 下载交叉编译工具,并安装 

     我下载的是:arm-2009q1-161-arm-none-eabi.bin 

     说明:要正确设置好PATH变量。 

     例如将“你的目录”/CodeSourcery/Sourcery_G++_Lite/bin加到PATH路径中。 

  

     3)进入到busybox解压后的源文件目录中,修改Makefile 

     将第176行改为: 

     CROSS_COMPILE   ?=arm-none-linux-gnueabi-

  

     4)进行编译选项配置 

     a、 

     $ make menuconfig 

     Busybox Settings ---> 

            Build Options ---> 

                [*] Build BusyBox as a static binary(no shared libs) 

 

  

     说明:这个选项一定要选,这样才能把busybox编译成静态链接的可执行文件,运行时可以独立于其他库。 

  

     b、 

            Installation Options ---> 

                [*] Don't use /usr   

  

     说明:这个也一定要选,否则make install后,busybox将安装在原来系统的/usr下,将你原有的命令都覆盖了! 

  

     5)配置好后可以编译了,执行如下命令: 

     $ make 

     发现没过多久,就报错了,晕,错误内容如下: 

     applets/applets.c:20:2: warning: #warning Static linking against glibc produces buggy executables 

     applets/applets.c:21:2: warning: #warning (glibc does not cope well with ld --gc-sections). 

     applets/applets.c:22:2: warning: #warning See sources.redhat.com/bugzilla/show_bug.cgi?id=3400 

     applets/applets.c:23:2: warning: #warning Note that glibc is unsuitable for static linking anyway. 

     applets/applets.c:24:2: warning: #warning If you still want to do it, remove -Wl,--gc-sections 

     applets/applets.c:25:2: warning: #warning from top-level Makefile and remove this warning. 

     applets/applets.c:26:2: error: #error Aborting compilation. 

     make[1]: *** [applets/applets.o] 错误1 

     make: *** [applets] 错误2 

     看到它给出了提示,说glibc库不适和用来静态编译,最后给出解决方案就是将applets/applets.c中这部分内容给去掉,也就是19-27行。 

     

     然后再make进行编译。 

     不多久又报错了,看看具体错误: 

     .../compal/CodeSourcery/Sourcery_G++_Lite/bin/../arm-none-linux-gnueabi/libc/usr/include/linux/netfilter.h:56:17: error: field 'in' has incomplete type 

     .../CodeSourcery/Sourcery_G++_Lite/bin/../arm-none-linux-gnueabi/libc/usr/include/linux/netfilter.h:57:18: error: field 'in6' has incomplete type 

     ipsvd/tcpudp.c: In function 'tcpudpsvd_main': 

     ipsvd/tcpudp.c:314:10: warning: ignoring return value of 'write', declared with attribute warn_unused_result 

     make[1]: *** [ipsvd/tcpudp.o] 错误1 

     make: *** [ipsvd] 错误2 

     看到说在我们下载的交叉编译库中有个头文件中的in及in6类型不对,解决的办法就是: 

     在.../arm-none-linux-gnueabi/libc/usr/include/linux/netfilter.h的开头 
添加缺少的头文件: 
     #include <netinet/in.h> 

  

     然后再进行编译。(这次可以安全到最后了,呵呵) 

     结束后会在当前目录下看到busybox这个可执行文件


你可能感兴趣的:(编译busybox)