android+busybox+编译,Android版busybox编译
Android版busybox編譯
1下載busybox源碼
2解壓
tar -xvf busybox-1.23.2.tar.bz2
3 android版的配置腳本
解壓后的源碼里,configs文件壓有android版本的配置腳本:
android2_defconfig?????? android_defconfig??????? android_ndk_defconfig
我選用的是android2_defconfig
4編譯arm版busybox
1)export arm的編譯工具:
export PATH=$PATH:/xxx/yyy/android_source/prebuilts/gcc/linux-x86/arm/arm-linux-androideabi-4.6/bin
2)修改編譯工具
打開android2_defconfig
將
CONFIG_CROSS_COMPILER_PREFIX=" arm-eabi-"
改為
CONFIG_CROSS_COMPILER_PREFIX="arm-linux-androideabi-"
3)修改sysroot路徑
由于arm-linux-androideabi-4.6目錄下沒有sysroot目錄,因此需要指定,否則編譯時(shí)會(huì)出現(xiàn)找不到一些頭文件的錯(cuò)誤,如:
include/platform.h:141:20: fatal error:limits.h: No such file or directory
compilation terminated.
make[1]: *** [applets/applets.o]錯(cuò)誤1
make: *** [applets_dir]錯(cuò)誤2
打開android2_defconfig
在CONFIG_CROSS_COMPILER_PREFIX下再添加一行:
CONFIG_SYSROOT=":/xxx/yyy/android_source/prebuilts/ndk/android-ndk-r7/platforms/android-14/arch-arm"
或者是在make android2_defconfig之后,進(jìn)入配置選項(xiàng)里改,其位置是在:
Busybox Settings? --->
BuildOptions? --->
()? Path to sysroot (NEW)
4)編譯
make android2_defconfig??????? //選項(xiàng)編譯腳本
make?????? //開始編譯
5編譯mips版busybox
1)export mips的編譯工具:
export PATH=$PATH:/xxx/yyy/android_source/prebuilts/gcc/linux-x86/mips/mipsel-linux-android-4.7/bin
2)修改編譯工具
打開android2_defconfig
將
CONFIG_CROSS_COMPILER_PREFIX="arm-eabi-"
改為
CONFIG_CROSS_COMPILER_PREFIX="mipsel-linux-android-"
3)修改sysroot路徑
mipsel-linux-android-4.7目錄下已包含sysroot目錄,不需要修改,默認(rèn)就行。
4)編譯
make android2_defconfig??????? //選項(xiàng)編譯腳本
make?????? //開始編譯
6編譯異常
編譯時(shí)會(huì)出現(xiàn)幾次錯(cuò)誤,處理原則是將該錯(cuò)誤對(duì)應(yīng)的工具選項(xiàng)關(guān)閉,實(shí)際上很多工具用不上,如果確實(shí)需要,才對(duì)錯(cuò)誤進(jìn)行修復(fù)。
下面是幾個(gè)錯(cuò)誤的處理過程:
Error:
coreutils/touch.c: In function'touch_main':
coreutils/touch.c:171:21: error: 'lutimes'undeclared (first use in this function)
coreutils/touch.c:171:21: note: eachundeclared identifier is reported only once for each function it appears in
make[1]: *** [coreutils/touch.o]錯(cuò)誤1
make: *** [coreutils]錯(cuò)誤2
Solution:
從coreutils/touch.c可看出是core utils里的touch工具出問題,所以進(jìn)入編譯選項(xiàng)coreutiles將touch的選項(xiàng)的勾去掉。如下:
make menuconfig? //配置編譯選項(xiàng)
Coreutils?--->
[*]touch
將touch去掉,然后退出保存,再繼續(xù)編譯。
Error:
networking/udhcp/dhcpc.c: In function'udhcp_recv_raw_packet':
networking/udhcp/dhcpc.c:852:24: error: invalidapplication of 'sizeof' to incomplete type 'struct tpacket_auxdata'
networking/udhcp/dhcpc.c:915:26: error:'PACKET_AUXDATA' undeclared (first use in this function)
networking/udhcp/dhcpc.c:915:26: note: eachundeclared identifier is reported only once for each function it appears in
networking/udhcp/dhcpc.c:922:11: error:dereferencing pointer to incomplete type
networking/udhcp/dhcpc.c:852:16: warning:unused variable 'cmsgbuf' [-Wunused-variable]
networking/udhcp/dhcpc.c: In function'udhcp_raw_socket':
networking/udhcp/dhcpc.c:1050:33: error:'PACKET_AUXDATA' undeclared (first use in this function)
make[1]: *** [networking/udhcp/dhcpc.o]錯(cuò)誤1
make: *** [networking/udhcp]錯(cuò)誤2
Solution:
去掉:
Networking Utilities? --->
[*]udhcp client (udhcpc)
Error:
libbb/lib.a(pw_encrypt.o): In function`pw_encrypt':
pw_encrypt.c:(.text.pw_encrypt+0x10):undefined reference to `crypt'
libbb/lib.a(replace.o): In function`xmalloc_substitute_string':
replace.c:(.text.xmalloc_substitute_string+0xa8):undefined reference to `mempcpy'
replace.c:(.text.xmalloc_substitute_string+0xbc):undefined reference to `mempcpy'
collect2: error: ld returned 1 exit status
make: *** [busybox_unstripped]錯(cuò)誤1
Solution:
Crypt錯(cuò)誤改起來麻煩,就直接將libbb/ pw_encrypt.c里的crypt(clear, salt);摒蔽掉了。
libbb/replace.c則將mempcpy改為memcpy
然后編譯就通過了,并在源碼根目錄下產(chǎn)生busybox,如果只是要提取busybox里的某個(gè)工具,則繼續(xù)下面的編譯。
7編譯出工具包
將Don't use/usr選項(xiàng)勾上,會(huì)將工具包編出到源碼根目錄下。
make menuconfig? //配置編譯選項(xiàng)
Busybox Settings? --->
GeneralConfiguration? --->
[*]Don't use /usr
make?//開始編譯
編譯完成后會(huì)生成_install文件夾,里面有各種工具文件。
總結(jié)
以上是生活随笔為你收集整理的android+busybox+编译,Android版busybox编译的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 可减少折痕,三星 Galaxy Z Fo
- 下一篇: 2023央视春晚主持人阵容公布:首次迎来