my busybox +android bionic + ndk tips, etc

Hin-Tak Leung htl10 at users.sourceforge.net
Mon Aug 29 19:21:12 UTC 2011


I have thought of filing a bug, but then there are too much loose information I'd like to post and probably are a few bug reports, so here they are: I have had a go at using the android ndk to build busybox against bionic, instead of against android source with an arm-targeted cross-gcc. (I think some of the recommendations online - using codesourcery's arm-gcc to build static, is just wrong).

1. Firstly, there is a useful but obscure tips: One can make a standalone toolchain from the ndk with:

<ndk_directory>/build/tools/make-standalone-toolchain.sh \
--platform=android-8

(default is android-3 which is very old).

2. There is a bunch of misc android-related patches on
http://matrixrewriter.com/wiki/
Notably, 
http://matrixrewriter.com/wiki/tiki-download_file.php?fileId=19
details a bunch of missing libc routines which are not in bionic's headers.

3. After looking at and applying some of the patches,
I found that I needed to remove a few more things in "configs/android_defconfig" (some of that are due to missing headers, some due to missing libc routines, see also 4.):

< # CONFIG_HOSTID is not set
< # CONFIG_WHO is not set
< # CONFIG_USERS is not set
< # CONFIG_LESS is not set
< # CONFIG_ARP is not set
< # CONFIG_IFCONFIG is not set
< # CONFIG_UPTIME is not set

4. At the final linker stage, here are a list of missing symbols:

ar.c: undefined reference to `dprintf'
bb_askpass.c: undefined reference to `fputs_unlocked'
cut.c: undefined reference to `fputs_unlocked'
dc.c: undefined reference to `pow'
dpkg.c: undefined reference to `fputs_unlocked'
dpkg.c: undefined reference to `fputc_unlocked'
e2fs_lib.c: undefined reference to `fputs_unlocked'
echo.c: undefined reference to `stpcpy'
expand.c: undefined reference to `fputs_unlocked'
fbsplash.c: undefined reference to `fgets_unlocked'
fbsplash.c: undefined reference to `strchrnul'
fdisk.c: undefined reference to `fgets_unlocked'
ftpgetput.c: undefined reference to `fgets_unlocked'
fuser.c: undefined reference to `fgets_unlocked'
get_cpu_count.c: undefined reference to `fgets_unlocked'
httpd.c: undefined reference to `strchrnul'
httpd.c: undefined reference to `dprintf'
httpd.c: undefined reference to `fputs_unlocked'
httpd.c: undefined reference to `fgets_unlocked'
iostat.c: undefined reference to `fgets_unlocked'
ipaddress.c: undefined reference to `fputs_unlocked'
iprule.c: undefined reference to `fputs_unlocked'
iptunnel.c: undefined reference to `fgets_unlocked'
isrv_identd.c: undefined reference to `dprintf'
klogd.c: undefined reference to `strchrnul'
lineedit.c: undefined reference to `fputs_unlocked'
lineedit.c: undefined reference to `fgets_unlocked'
lpr.c: undefined reference to `dprintf'
ls.c: undefined reference to `strverscmp'
ls.c: undefined reference to `strchrnul'
ls.c: undefined reference to `fputs_unlocked'
man.c: undefined reference to `strchrnul'
modprobe-small.c: undefined reference to `strchrnul'
modutils.c: undefined reference to `strchrnul'
mpstat.c: undefined reference to `fgets_unlocked'
parse_config.c: undefined reference to `strchrnul'
parse_config.c: undefined reference to `getline'
patch.c: undefined reference to `dprintf'
popmaildir.c: undefined reference to `fputs_unlocked'
powertop.c: undefined reference to `fputs_unlocked'
printable.c: undefined reference to `fputs_unlocked'
procps.c: undefined reference to `fgets_unlocked'
readprofile.c: undefined reference to `fgets_unlocked'
reformime.c: undefined reference to `fputs_unlocked'
rev.c: undefined reference to `fputs_unlocked'
rev.c: undefined reference to `fgets_unlocked'
rtc.c: undefined reference to `fgets_unlocked'
runsv.c: undefined reference to `stpcpy'
seq.c: undefined reference to `strchrnul'
strings.c: undefined reference to `fputs_unlocked'
stty.c: undefined reference to `fputs_unlocked'
tail.c: undefined reference to `dprintf'
top.c: undefined reference to `fgets_unlocked'
top.c: undefined reference to `fputs_unlocked'
unzip.c: undefined reference to `fgets_unlocked'
wget.c: undefined reference to `fgets_unlocked'
wget.c: undefined reference to `strchrnul'
whois.c: undefined reference to `dprintf'
whois.c: undefined reference to `fgets_unlocked'
xargs.c: undefined reference to `fputs_unlocked'
yes.c: undefined reference to `fputs_unlocked'

Some of these are relatively easy to fix e.g. strchrnul can be replaced with a simply strchr-based macro.

5. The android ndk compiler preprocessor defines 
#define __ANDROID__ 1
this is probably useful to distinguish it from other ARM-targeted cross-gcc's.

I hope this info is useful to somebody... and hope that busybox can be built cleanly with the android ndk soon... :-).



More information about the busybox mailing list