日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 运维知识 > windows >内容正文

windows

64位ubuntu 12.04系统编译busybox遇到的问题处理办法

發(fā)布時間:2023/12/15 windows 23 豆豆
生活随笔 收集整理的這篇文章主要介紹了 64位ubuntu 12.04系统编译busybox遇到的问题处理办法 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

今天研究了一下busybox的編譯。自己下了一個busybox-1.25.0的版本(直接從busybox官網(wǎng)上下載:https://busybox.net/downloads/),進(jìn)行編譯,遇到了一些問題,通過百度搜索和自己摸索,也成功解決了,詳細(xì)記錄如下:

首先交代一下系統(tǒng)版本和開發(fā)環(huán)境:

  • 操作系統(tǒng):ubuntu 12.04(64bit)
  • 交叉編譯工具鏈:arm-linux-gcc 4.4.3
  • busybox源碼包:busybox-1.25.0

一、修改Makefile配置

首先解壓源碼包:

tar -jxvf busybox-1.25.0.tar.bz2

進(jìn)入busybox-1.25.0目錄,修改Makefile文件如下:

ARCH ?= arm CROSS_COMPILE ?= arm-linux-

二、修改配置文件

make menuconfig

選擇Busybox Settings—>Build Options—>,選擇[*] Build Busybox as a static binary(no shared libs);

三、編譯源碼,解決問題

make clean make

出現(xiàn)如下錯誤:

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 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

解決辦法:

MTD_FILE_MODE_RAW在/usr/include/mtd/mtd-abi.h中定義,于是將/usr/include/mtd/mtd-abi.h拷貝到busybox的include文件中,然后在nandwrite.c文件中包含該頭文件:

gedit miscutils/nandwrite.c

修改

#include "libbb.h" #include <mtd/mtd-user.h>

#include "libbb.h" #include "mtd-abi.h" #include <mtd/mtd-user.h>

此問題解決。繼續(xù)make,又出現(xiàn)如下錯誤:

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.) 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

解決辦法:

BLKSECDISCARD在/usr/include/linux/fs.h中定義,同上理,直接將/usr/include/linux/fs.h拷貝到busybox的include文件中,不過這次還要額外修改一下文件中的部分內(nèi)容,否則會出現(xiàn)編譯失敗。

1、屏蔽以下4個頭文件(否則編譯時會提示找不到頭文件):

//#include <linux/limits.h> //#include <linux/ioctl.h> //#include <linux/blk_types.h> //#include <linux/types.h>

2、屏蔽以下幾個結(jié)構(gòu)體(否則編譯時會提示找不到類型定義):

#if 0 struct 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

然后修改blkdiscard.c中對fs.h頭文件的包含方式:

gedit util-linux/blkdiscard.c

修改

#include <linux/fs.h>

#include "fs.h"

繼續(xù)make,編譯能通過了。但是在鏈接的時候出現(xiàn)問題:

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 linking debianutils/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 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 libraries 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

解決辦法:

make menuconfig

Linux System Utilities—>nsenter,去掉該選項,重新編譯make,又出現(xiàn)如下錯誤:

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 linking debianutils/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 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 libraries 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

解決辦法:

make menuconfig

Coreutils—>sync選項去掉,重新make編譯通過,終于順利生成了busybox可執(zhí)行文件。

OK,今天到此為止,明天再繼續(xù)研究。

搞定,收工!


篇后語:

1、編譯完后對上述幾個問題進(jìn)行反思,發(fā)現(xiàn)這幾個問題其實來講可以分為2類。一類是頭文件包含的問題,一類是make menuconfig配置的問題。后者,可能跟每個人的配置需求有關(guān)。但是前者的問題,我認(rèn)為busybox公司完全可以將那2個頭文件直接包含在源碼包中,將相關(guān)代碼修改成OK的狀態(tài),讓我們下載過來就可以直接編譯通過,免去我們這番折騰。但是為何busybox公司沒有這么做呢?其中應(yīng)該是有原因的,暫時想不通,待日后再仔細(xì)琢磨吧。

2、本文撰寫時,使用的busybox工具源碼版本是busybox-1.25.0,使用上述方法驗證通過。不過,緊接著,我又驗證了最新的busybox-1.26.2版本,同樣使用上述方法,順利通過,編譯成功。證明本文中的方法應(yīng)該對于各個版本都是通用的。

3、本文只是簡單的介紹了一下使用busybox過程中遇到幾個編譯出錯的問題的解決辦法,并未對整套編譯流程進(jìn)行詳細(xì)介紹。關(guān)于如何利用busybox工具編譯出linux根文件系統(tǒng)的完整流程,可參見我的另外一篇博客(如何使用busybox編譯和生成最簡linux根文件系統(tǒng)(rootfs))。

總結(jié)

以上是生活随笔為你收集整理的64位ubuntu 12.04系统编译busybox遇到的问题处理办法的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。