Compile BusyBox On Android OS

Busybox is a set of frequent-used unix tools, including awk, ifconfig, route, ip … etc.
If you would like to enjoy the shell in android ‘just like under unix’, busybox is a great tool to have on your android.
Here we provide some info on how to cross-compile busybox for android system.

  1. Download BusyBox Source Code
  2. You can get the source code from the BusyBox Official WebSite.

  3. Download ARM Cross-Compiler
  4. You can get the cross-compiler from codesourcery.com.
    Note: I tried to use the arm-eabi-* compiler in android_ndk, but it seems to need a lot of configurations (such as sysroot, etc.). Thus, I choose to use arm-none-linux-gnueabi-* compiler, it will make the following steps a lot easier.

  5. Setup .config File
  6. $ make menuconfig

    Select Busybox setting -> Build options -> select Build BusyBox as a static binary (no shared libs)
    and Set Cross Compiler prefix as “arm-none-linux-gnueabi-”

    $ make
    
  7. Push BusyBox into Android
  8. $ adb shell "mount -o rw,remount -t yaffs2 /dev/block/mtdblock3 /system"
    $ adb shell "chmod 0777 /system/xbin"
    $ adb push busybox /system/xbin/
    $ adb shell "chmod 755 /system/xbin/busybox"
    $ adb shell "chmod 0755 /system/xbin"
    
  9. Usage of BusyBox
  10. $ busybox ifconfig
    

Feb28

14 Responses to “Compile BusyBox On Android OS”

  1. perfect site and provide the latest information for the world community. please give comments to my site : http://aboutandroidapps.com/

    thank’s

  2. It was very much helpful .
    I compiled the basybox using the cross-compiler from codesourcery.com.
    But program compiled using “arm-linux-gnueabi-gcc” does not executes in android .It gives Illegal instruction error.If you know the options (arguments) for “arm-linux-gnueabi-gcc” to produce android compatible binary,Please post it

    Thank you for this informative news

  3. My tablets, Kindle fire & Playbook are dull. Where can I see an Android x86 netbook?
    Glenn S (shnkr888 AT aol DOT com)

  4. Hi, I an trying with “arm-eabi-” toolchain and it is is giving lots of error. Would you tell me what configuration we have to set??

  5. Thanks for the tutorial. I wish you could also create a tutorial using the NDK compiler which I think would be much easier to use. Thank you

  6. When pushing it to my phone it says

    ‘adb’ is not recognized as an internal or external command,
    operable program or batch file.

    What is wrong?

    • hackitboy Says:
      June 8, 2012 at 10:43 am

      Do you have all the android tools installed? If you have it installed, then probably you have not updated your env variable “PATH”.

  7. I had the problem

    scripts/kconfig/lxdialog/dialog.h:31:20: fatal error: curses.h: No such file or directory

    So I had to install libncurses5-dev on ubuntu.

  8. I had this problem:

    mitch@ubuntu:~/Downloads/busybox-1.20.2$ make menuconfig
    HOSTCC scripts/kconfig/lxdialog/checklist.o
    HOSTCC scripts/kconfig/lxdialog/inputbox.o
    HOSTCC scripts/kconfig/lxdialog/lxdialog.o
    scripts/kconfig/lxdialog/lxdialog.c: In function ‘j_inputbox’:
    scripts/kconfig/lxdialog/lxdialog.c:192:3: warning: format not a string literal and no format arguments [-Wformat-security]
    HOSTCC scripts/kconfig/lxdialog/menubox.o
    HOSTCC scripts/kconfig/lxdialog/msgbox.o
    HOSTCC scripts/kconfig/lxdialog/textbox.o
    HOSTCC scripts/kconfig/lxdialog/util.o
    HOSTCC scripts/kconfig/lxdialog/yesno.o
    HOSTLD scripts/kconfig/lxdialog/lxdialog
    scripts/kconfig/mconf Config.in
    #
    # using defaults found in /dev/null
    #

    *** End of configuration.
    *** Execute ‘make’ to build the project or try ‘make help’.

    I solved it with:
    sudo apt-get install libncurses5-dev

    • mitch@ubuntu:~/Downloads/busybox-1.20.2$ make menuconfig
      HOSTCC scripts/kconfig/lxdialog/checklist.o
      In file included from scripts/kconfig/lxdialog/checklist.c:24:0:
      scripts/kconfig/lxdialog/dialog.h:31:20: fatal error: curses.h: No such file or directory
      compilation terminated.
      make[2]: *** [scripts/kconfig/lxdialog/checklist.o] Error 1
      make[1]: *** [menuconfig] Error 2
      make: *** [menuconfig] Error 2

  9. eliaspizarro Says:
    February 5, 2013 at 2:43 pm

    how about busybox for x86 phones

  10. [...]            参考文章:http://mobisocial.stanford.edu/news/2011/02/compile-busybox-on-android-os/ [...]

  11. [...]            参考文章:http://mobisocial.stanford.edu/news/2011/02/compile-busybox-on-android-os/ [...]

Leave a Reply