busybox-1.26.2编译

busybox-1.26.2编译

root@ubuntu:/home/luoyu/share/freescale_kernel_rc/busybox-1.26.2# arm-none-linux-gnueabi-gcc -v
Using built-in specs.
Target: arm-fsl-linux-gnueabi
Configured with: /work/arm-toolchains/tmp/src/gcc-4.4.4/configure --build=i686-build_pc-linux-gnu --host=i686-build_pc-linux-gnu --target=arm-fsl-linux-gnueabi --prefix=/work/arm_fsl_gcc_4.4.4_multilib --with-sysroot=/work/arm_fsl_gcc_4.4.4_multilib/arm-fsl-linux-gnueabi/multi-libs --enable-languages=c,c++ --with-pkgversion=4.4.4_09.06.2010 --enable-__cxa_atexit --disable-libmudflap --with-host-libstdcxx=‘-static-libgcc -Wl,-Bstatic,-lstdc++,-Bdynamic -lm’ --with-gmp=/work/arm-toolchains/tmp/arm-fsl-linux-gnueabi/build/static --with-mpfr=/work/arm-toolchains/tmp/arm-fsl-linux-gnueabi/build/static --with-ppl=/work/arm-toolchains/tmp/arm-fsl-linux-gnueabi/build/static --with-cloog=/work/arm-toolchains/tmp/arm-fsl-linux-gnueabi/build/static --enable-threads=posix --enable-target-optspace --with-local-prefix=/work/arm_fsl_gcc_4.4.4_multilib/arm-fsl-linux-gnueabi/multi-libs --disable-nls --enable-symvers=gnu --enable-c99 --enable-long-long --enable-multilib --with-system-zlib --enable-lto
Thread model: posix
gcc version 4.4.4 (4.4.4_09.06.2010)

一、修改Makefile配置

首先解压源码包:

tar -jxvf busybox-1.25.0.tar.bz2

进入busybox-1.25.0目录,修改Makefile文件如下:

ARCH ?= $(SUBARCH)
ARCH = arm

CROSS_COMPILE =arm-none-linux-gnueabi-

二、修改配置文件

make menuconfig

选择Busybox Settings—>Build Options—>,选择[*] Build Busybox as a static binary(no shared libs)

三、编译

make

出现如下错误:

miscutils/nandwrite.c: In function ‘nandwrite_main’:
miscutils/nandwrite.c:151: error: ‘MTD_FILE_MODE_RAW’ undeclared (first use in this function)
miscutils/nandwrite.c:151: error: (Each undeclared identifier is reported only once

解决在主机/usr目录下
root@ubuntu:/usr# grep “MTD_FILE_MODE_RAW” * -R
知道后数值为3 直接在出错文件中#define MTD_FILE_MODE_RAW 3

继续make,出现如下错误:

util-linux/blkdiscard.c: In function ‘blkdiscard_main’:
util-linux/blkdiscard.c:72: error: ‘BLKSECDISCARD’ undeclared (first use in this function)
util-linux/blkdiscard.c:72: error: (Each undeclared identifier is reported only once
util-linux/blkdiscard.c:72: error: for each function it appears in.)

解决办法
在/usr目录
root@ubuntu:/usr# grep “BLKSECDISCARD” * -R
在util-linux/blkdiscard.c中添加
#define BLKSECDISCARD _IO(0x12,125)

或者

BLKSECDISCARD在/usr/include/linux/fs.h中定义,方法如上所述,将/usr/include/linux/fs.h拷贝到busybox的include文件中,然后修改blkdiscard.c中头文件包含:

修改:#include 为#include “fs.h”

继续make,编译通过,但是在链接的时候出现问题:

netstat.c:(.text.ip_port_str+0x50): warning: Using ‘getservbyport’ in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
util-linux/lib.a(nsenter.o): In function nsenter_main': nsenter.c:(.text.nsenter_main+0x1b0): undefined reference to setns’
collect2: ld returned 1 exit status
Note: if build needs additional libraries, put them in CONFIG_EXTRA_LDLIBS.
Example: CONFIG_EXTRA_LDLIBS=“pthread dl tirpc audit pam”
Makefile:717: recipe for target ‘busybox_unstripped’ failed
make: *** [busybox_unstripped] Error 1

解决办法:

make menuconfig

Linux System Utilities—>nsenter,去掉该选项,重新编译make,又出现如下错误:

netstat.c:(.text.ip_port_str+0x50): warning: Using ‘getservbyport’ in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
coreutils/lib.a(sync.o): In function sync_main': sync.c:(.text.sync_main+0x7c): undefined reference to syncfs’
collect2: ld returned 1 exit status
Note: if build needs additional libraries, put them in CONFIG_EXTRA_LDLIBS.
Example: CONFIG_EXTRA_LDLIBS=“pthread dl tirpc audit pam”
Makefile:717: recipe for target ‘busybox_unstripped’ failed
make: *** [busybox_unstripped] Error 1

解决办法:

make menuconfig

Coreutils—>sync选项去掉,重新make编译通过,生成了busybox可执行文件。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

xx-xx-xxx-xxx

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值