busybox-1.26.2编译

发布时间:2026/5/20 11:52:25

busybox-1.26.2编译 busybox-1.26.2编译rootubuntu:/home/luoyu/share/freescale_kernel_rc/busybox-1.26.2# arm-none-linux-gnueabi-gcc -vUsing built-in specs.Target: arm-fsl-linux-gnueabiConfigured with: /work/arm-toolchains/tmp/src/gcc-4.4.4/configure --buildi686-build_pc-linux-gnu --hosti686-build_pc-linux-gnu --targetarm-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-languagesc,c --with-pkgversion4.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-threadsposix --enable-target-optspace --with-local-prefix/work/arm_fsl_gcc_4.4.4_multilib/arm-fsl-linux-gnueabi/multi-libs --disable-nls --enable-symversgnu --enable-c99 --enable-long-long --enable-multilib --with-system-zlib --enable-ltoThread model: posixgcc 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 armCROSS_COMPILE arm-none-linux-gnueabi-二、修改配置文件make menuconfig选择Busybox Settings—Build Options—选择[*] Build Busybox as a static binaryno 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目录下rootubuntu:/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 onceutil-linux/blkdiscard.c:72: error: for each function it appears in.)解决办法在/usr目录rootubuntu:/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_str0x50): warning: Using ‘getservbyport’ in statically linked applications requires at runtime the shared libraries from the glibc version used for linkingutil-linux/lib.a(nsenter.o): In functionnsenter_main: nsenter.c:(.text.nsenter_main0x1b0): undefined reference tosetns’collect2: ld returned 1 exit statusNote: 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’ failedmake: *** [busybox_unstripped] Error 1解决办法make menuconfigLinux System Utilities—nsenter去掉该选项重新编译make又出现如下错误netstat.c:(.text.ip_port_str0x50): warning: Using ‘getservbyport’ in statically linked applications requires at runtime the shared libraries from the glibc version used for linkingcoreutils/lib.a(sync.o): In functionsync_main: sync.c:(.text.sync_main0x7c): undefined reference tosyncfs’collect2: ld returned 1 exit statusNote: 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’ failedmake: *** [busybox_unstripped] Error 1解决办法make menuconfigCoreutils—sync选项去掉重新make编译通过生成了busybox可执行文件。

相关新闻