System environment:
1. Operating system: Ubuntu16.04
2. Cross-compiling tool chain: arm-linux-gcc4.4.3
3, BusyBox source package: busybox-1.25.0
First, modify the makefile configuration
First unpack the source package:
TAR-JXVF busybox-1.25.0.tar.bz2
Enter the busybox-1.25.0 directory and modify the makefile file as follows:
ARCH? = Arm
Cross_compile? = arm-linux-
Second, modify the configuration file
Make Menuconfig
Choose Busybox Settings--->build options---, select [*] Build Busybox as a static binary (no shared libs)
Third, compile
Make
The following error occurred:
miscutils/nandwrite.c:in function ' Nandwrite_main ':
Miscutils/nandwrite.c:151:error: ' Mtd_file_mode_raw ' undeclared (first use of this function)
Miscutils/nandwrite.c:151:error: (Each undeclared identifier was reported only once
Miscutils/nandwrite.c:151:error:for each function it appears in.)
Scripts/makefile.build:197:recipe for Target ' MISCUTILS/NANDWRITE.O ' failed
MAKE[1]: * * * [MISCUTILS/NANDWRITE.O] Error 1
Makefile:742:recipe for Target ' miscutils ' failed
Make: * * * [miscutils] Error 2
Workaround:
Mtd_file_mode_raw is defined in/usr/include/mtd/mtd-abi.h, and the inclusion of <mtd/mtd-abi.h> compiles directly in the nandwrite.c still fails. Copy the /usr/include/mtd/mtd-abi.h to the busybox include file, and then include the header file:
#include "Libbb.h"
#include "mtd-abi.h"
#include <mtd/mtd-user.h>
Compilation can be done by.
To continue make, the following error occurred:
util-linux/blkdiscard.c:in function ' Blkdiscard_main ':
Util-linux/blkdiscard.c:72:error: ' Blksecdiscard ' undeclared (first use of this function)
Util-linux/blkdiscard.c:72:error: (Each undeclared identifier was reported only once
Util-linux/blkdiscard.c:72:error:for each function it appears in.)
Scripts/makefile.build:197:recipe for Target ' UTIL-LINUX/BLKDISCARD.O ' failed
MAKE[1]: * * * [UTIL-LINUX/BLKDISCARD.O] Error 1
Makefile:742:recipe for Target ' Util-linux ' failed
Make: * * * [Util-linux] Error 2
Workaround:
Blksecdiscard is defined in/usr/include/linux/fs.h, and the method described above will/usr/include/linux/ Fs.h Copy to the busybox include file, and then modify the BLKDISCARD.C in the header file that contains:
Modified: #include <linux/fs.h> for
#include "Fs.h"
Continue make, compile through, but there is a problem with the link:
NETWORKING/LIB.A (NSLOOKUP.O): in function ' Print_host ':
NSLOOKUP.C: (. text.print_host+0x44): warning:using ' getaddrinfo ' in statically linked applications requires at runtime th E shared libraries from the GLIBC version used for linking
DEBIANUTILS/LIB.A (MKTEMP.O): in function ' Mktemp_main ':
MKTEMP.C: (. text.mktemp_main+0x98): warning:the use of ' mktemp ' are dangerous, better use ' mkstemp '
NETWORKING/LIB.A (IPCALC.O): in function ' Ipcalc_main ':
IPCALC.C: (. text.ipcalc_main+0x25c): warning:using ' gethostbyaddr ' in statically linked applications requires at runtime The shared libraries from the GLIBC version used for linking
LIBBB/LIB.A (INET_COMMON.O): in function ' Inet_resolve ':
INET_COMMON.C: (. Text. inet_resolve+0x60): warning:using ' gethostbyname ' in statically linked applications requires at runtime the shared Librar IES from the glibc version used for linking
NETWORKING/LIB.A (INETD.O): in function ' Reread_config_file ':
INETD.C: (. text.reread_config_file+0x230): warning:using ' Getservbyname ' in statically linked applications requires at Runtime the shared libraries from the GLIBC version used for linking
NETWORKING/LIB.A (NETSTAT.O): in function ' Ip_port_str ':
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
Workaround:
Make Menuconfig
Linux System Utilities--->nsenter, remove this option, recompile make, and the following error occurs:
NETWORKING/LIB.A (NSLOOKUP.O): in function ' Print_host ':
NSLOOKUP.C: (. text.print_host+0x44): warning:using ' getaddrinfo ' in statically linked applications requires at runtime th E shared libraries from the GLIBC version used for linking
DEBIANUTILS/LIB.A (MKTEMP.O): in function ' Mktemp_main ':
MKTEMP.C: (. text.mktemp_main+0x98): warning:the use of ' mktemp ' are dangerous, better use ' mkstemp '
NETWORKING/LIB.A (IPCALC.O): in function ' Ipcalc_main ':
IPCALC.C: (. text.ipcalc_main+0x25c): warning:using ' gethostbyaddr ' in statically linked applications requires at runtime The shared libraries from the GLIBC version used for linking
LIBBB/LIB.A (INET_COMMON.O): in function ' Inet_resolve ':
INET_COMMON.C: (. Text. inet_resolve+0x60): warning:using ' gethostbyname ' in statically linked applications requires at runtime the shared Librar IES from the glibc version used for linking
NETWORKING/LIB.A (INETD.O): in function ' Reread_config_file ':
INETD.C: (. text.reread_config_file+0x230): warning:using ' Getservbyname ' in statically linked applications requires at Runtime the shared libraries from the GLIBC version used for linking
NETWORKING/LIB.A (NETSTAT.O): in function ' Ip_port_str ':
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
Workaround:
Make Menuconfig
Coreutils---The >sync option is removed, and the BusyBox executable is generated by re-compiling.
What the specific options mean is unclear and needs further understanding.
arm-linux-gcc4.4.3 compiling busybox-1.25.0