编译busybox

来源:互联网 发布:nodejs json 编辑:程序博客网 时间:2024/06/04 19:46

1、编译busybox

 

交叉编译器: 3.4.1,我使用的是1.4.1版的BUSYBOX

# tar jxvf busybox-1.4.1.tar.bz2

修改源码、配置、编译

-----------------------------------------------
# cd busybox-1.4.1
修改 Makefile

ARCH            ?= arm
CROSS_COMPILE   ?= /usr/local/arm/3.4.1/bin/arm-linux-

# make menuconfig
Busybox Settings --->
    Build Options --->
        [*] Build BusyBox as a static binary (no shared libs) //
这样就省去了寻找共享库的麻烦

Installation Options --->
        [*] Don't use /usr              

Linux System Utilities --->
    [*] mdev                             //
成功移植完2.6.19后,由于没有启动udev,造成/dev下没有     设备文件。也就是说所有的设备都没有挂接进来。最新的busybox已经包含了udev的简化版本即mdev,且使用非常简单。 要使用mdev还需要在root filesystem中做适当配置。

    [*] Support /etc/mdev.conf
    [*] Support command execution at device addition/removal

Shells --->   
    Choose your default shell (ash) --->

 

   

# make
# make install

 

这时会在你的编译目录下生成一个_install的目录,里面包含了生成的所有文件和目录结构。


mdev的运行准备环境
-----------------------------------------------
    mdev
需要改写/dev/sys两个目录。所以必须保证这两个目录是可写的(一般会用到sysfs,tmpfs。所以要重新编译内核)。然后在你的启动脚本文件中加入/sbin/mdev –s

 

linux-2.6.19 -- make menuconfig
File systems --->
    Pseudo filesystems --->
        [*] sysfs file system support  
        [*] Virtual memory file system support (former shm fs)
        [*]   Tmpfs POSIX Access Control Lists

 

编译busybox时遇到的问题:

如果是静态编译的话

Busybox Settings --->
    Build Options --->
        [*] Build BusyBox as a static binary (no shared libs)

# make
将会遇到下面问题:

applets/applets.c:20:2: error: #warning Static linking against glibc produces buggy executables
applets/applets.c:21:2: error: #warning (glibc does not cope well with ld --gc-sections).
applets/applets.c:22:2: error: #warning See sources.redhat.com/bugzilla/show_bug.cgi?id=3400
applets/applets.c:23:2: error: #warning Note that glibc is unsuitable for static linking anyway.
applets/applets.c:24:2: error: #warning If you still want to do it, remove -Wl,--gc-sections
applets/applets.c:25:2: error: #warning from top-level Makefile and remove this warning.
make[1]: *** [applets/applets.o] Error 1

这个警告的定义在applets/applets.c中。将这段警告注释掉就可以了。这段警告的意思是告诉你最好用uclibc编译,而不是用glibc因为glibc比较大,在嵌入式系统中,对空间占用要求较高,所以会有这样的要求。

# vi /busybox-1.4.1/applets/applets.c +20
注释掉20 -- 28行内容即可


# vi applets/applets.c
/*
#if ENABLE_STATIC && defined(__GLIBC__) && !defined(__UCLIBC__)
#warning Static linking against glibc produces buggy executables
#warning (glibc does not cope well with ld --gc-sections).
#warning See sources.redhat.com/bugzilla/show_bug.cgi?id=3400
#warning Note that glibc is unsuitable for static linking anyway.
#warning If you still want to do it, remove -Wl,--gc-sections
#warning from top-level Makefile and remove this warning.
#error Aborting compilation.
#endif
*/

miscutils/taskset.c:17: error: parse error before '*' token

-----------------------------------------------

 

最根本的解决办法是换一个libc库,可是现在还不知道哪个库最合适,唯有暂时将有问题的命令关掉

Miscellaneous Utilities --->
    [ ] taskset

Runit Utilities --->
    [ ] runsv  

 

内核启动时遇到的问题:
“could not run '/bin/sh': No such file or directory”
解决方法
:
要这样配置:

Shells --->   
    Choose your default shell (ash) --->     
如果是这样配置的话,虽然可以生成ash,但不能生成sh,将会在内核启动时出现上面出现的问题:
Shells --->   
    Choose your default shell (ash) --->
[*] ash

 

这样,编译完成之后,在busybox目录下会生成一个_install目录,里面有/bin/sbin以及一个linuxrc文件!

阅读(1504) | 评论(0) | 转发(0) |
0

上一篇:移植linux2.6.19成功^_^

下一篇:建立根文件系统目录

相关热门文章
  • 以游戏邦为例谈游戏网站的运营...
  • 简述HTML的基本工具
  • varnish-cache 安装配置及体验...
  • 简易通用数据库API c++ wrappe...
  • 阿里云 C SDK应用集锦
  • linux 常见服务端口
  • 什么是shell
  • linux socket的bug??
  • 【ROOTFS搭建】busybox的httpd...
  • linux的线程是否受到了保护?...
  • 如何编写一个C程序实现将字符...
  • C程序能不能在main函数之前调...
  • 看一个程序调用了哪些动态库用...
  • 回复不了你啊,咋,威望值不够...
  • mysql的medium.cnf在哪里?...
给主人留下些什么吧!~~
原创粉丝点击