Solution for compiling busybox problems, busybox Solution

Source: Internet
Author: User
Tags nslookup ipcalc

Solution for compiling busybox problems, busybox Solution

Today I have studied compilation of busybox. Under a busybox-1.25.0 version, compile, encountered some problems, through Baidu search and their own exploration, also successfully solved, detailed records are as follows:

First, explain the system version and development environment:

Operating System: ubuntu 12.04 (64bit)

Tool chain for cross-Compilation: arm-linux-gcc 4.4.3

Busybox source package: busybox-1.25.0

1. Modify Makefile Configuration

First extract 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 ?= armCROSS_COMPILE ?= arm-linux-

Ii. modify the configuration file

make menuconfig

Select Busybox Settings-> Build Options-> and select [*] Build Busybox as a static binary (no shared libs );

3. Compile the source code to solve the problem

make cleanmake

The following error occurs:

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 oncemiscutils/nandwrite.c:151: error: for each function it appears in.)scripts/Makefile.build:197: recipe for target 'miscutils/nandwrite.o' failedmake[1]: *** [miscutils/nandwrite.o] Error 1Makefile:742: recipe for target 'miscutils' failedmake: *** [miscutils] Error 2

Solution:

MTD_FILE_MODE_RAW is defined in/usr/include/mtd/mtd-abi.h, so the/usr/include/mtd/mtd-abi.h is copied to the include file in busybox, and then in nandwrite. the c file contains the header file:

gedit miscutils/nandwrite.c 

Modify

#include "libbb.h"#include 

Is

#include "libbb.h"#include "mtd-abi.h"#include 

Solve this problem. Continue to make, and the following error occurs:

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.)scripts/Makefile.build:197: recipe for target 'util-linux/blkdiscard.o' failedmake[1]: *** [util-linux/blkdiscard.o] Error 1Makefile:742: recipe for target 'util-linux' failedmake: *** [util-linux] Error 2

Solution:

BLKSECDISCARD in/usr/include/linux/fs. h, as defined above, directly add/usr/include/linux/fs. h: Copy It To The include file of busybox. However, you need to modify part of the file this time. Otherwise, compilation may fail.

1. shield the following four header files (otherwise, the header file cannot be found during compilation ):

//#include 
 
  //#include 
  
   //#include 
   
    //#include 
   
  
 

2. Block the following struct (otherwise, the system will prompt that the type definition cannot be found during compilation ):

#if 0struct fstrim_range {    __u64 start;    __u64 len;    __u64 minlen;};/* And dynamically-tunable limits and defaults: */struct files_stat_struct {    unsigned long nr_files;     /* read only */    unsigned long nr_free_files;    /* read only */    unsigned long max_files;        /* tunable */};struct inodes_stat_t {    int nr_inodes;    int nr_unused;    int dummy[5];       /* padding for sysctl ABI compatibility */};#endif

Then modify the Inclusion Method of the fs. h header file in blkdiscard. c:

gedit util-linux/blkdiscard.c

Modify

#include 

Is

#include "fs.h"

Continue to make. The compilation is successful. But there is a problem during 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 the shared libraries from the glibc version used for linkingdebianutils/lib.a(mktemp.o): In function `mktemp_main':mktemp.c:(.text.mktemp_main+0x98): warning: the use of `mktemp' is 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 linkinglibbb/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 libraries from the glibc version used for linkingnetworking/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 linkingnetworking/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 linkingutil-linux/lib.a(nsenter.o): In function `nsenter_main':nsenter.c:(.text.nsenter_main+0x1b0): undefined reference to `setns'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 

Solution:

make menuconfig

Linux System Utilities-> nsenter, remove this option, re-compile 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 the shared libraries from the glibc version used for linkingdebianutils/lib.a(mktemp.o): In function `mktemp_main':mktemp.c:(.text.mktemp_main+0x98): warning: the use of `mktemp' is 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 linkinglibbb/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 libraries from the glibc version used for linkingnetworking/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 linkingnetworking/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 linkingcoreutils/lib.a(sync.o): In function `sync_main':sync.c:(.text.sync_main+0x7c): undefined reference to `syncfs'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

Solution:

make menuconfig

Coreutils-> sync option removed, re-make compiled, and finally generate the busybox executable file.

OK. So far today, we will continue our research tomorrow.

Get it done, close the job!

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.