Chinaunix首页 | 论坛 | 博客
  • 博客访问: 316915
  • 博文数量: 90
  • 博客积分: 4010
  • 博客等级: 上校
  • 技术积分: 694
  • 用 户 组: 普通用户
  • 注册时间: 2009-05-22 10:51
文章分类

全部博文(90)

文章存档

2011年(3)

2010年(35)

2009年(52)

我的朋友

分类: LINUX

2009-06-17 09:27:34

1. 如何編譯2. 常見問題
- 如何將 busybox 編譯成 static linking
- make menuconfig 出現下列錯誤
In file included from scripts/kconfig/lxdialog/checklist.c:24:

環境
glibc-2.4-7mdv2007.0
gcc-4.1.1-3mdk
make-3.81-1mdv2007.0
binutils-2.16.91.0.7-3mdv2007.0


1. 如何編譯

- 先編一個 .config 之後備用

$ make defconfig

- 用 make menuconfig 選單方式方便選取

$ make menuconfig

一些參考選項


Init Utilities 下:

  init

  這個選上,用busybox來初始化系統。

  debugging aid

  這個會在使用inittab初始化時顯示額外的信息,我沒選

Login/Password Management Utilities下:

  Use internal password and group functions rather than system functions

  這個如果不選上,busybox會認不了lib下的libnss,然後解析不了uid...

Shells下:

  選擇ash

  Job control

  這個選上(雖然在/dev/console下用不了——直接造成不能ctrl+c,這是最鬱悶的)

  Standalone shell

  不選。很奇怪,選上後PATH這個環境變量似乎就無效了-.-

  Command line editing


- 編譯

$ make

- 驗證需要哪些 liberary


# ldd busybox

linux-gate.so.1 => (0xbfffe000)

libcrypt.so.1 => /lib/libcrypt.so.1 (0xb7ece000)

libm.so.6 => /lib/i686/libm.so.6 (0xb7ea9000)

libc.so.6 => /lib/i686/libc.so.6 (0xb7d7c000)

/lib/ld-linux.so.2 (0xb7f0b000)

2. 常見問題

- 如何將 busybox 編譯成 static linking


Busybox Settings -> Build Options 下:

  Build BusyBox as a static binary (no shared libs)


$ make 

會遇到


applets/applets.c:20:2: error: #warning Static linking against glibc produces buggy executables

applets/applets.c:21:2: error: #warning (glibc does not cope well with ld --gc-sections).

applets/applets.c:22:2: error: #warning See sources.redhat.com/bugzilla/show_bug.cgi?id=3400

applets/applets.c:23:2: error: #warning Note that glibc is unsuitable for static linking anyway.

applets/applets.c:24:2: error: #warning If you still want to do it, remove -Wl,--gc-sections

applets/applets.c:25:2: error: #warning from top-level Makefile and remove this warning.

make[1]: *** [applets/applets.o] Error 1

這個警告的定義在applets/applets.c中,將這段警告註釋掉就可以了。

這段的意思就是告訴你最好用uclibc編譯,而不用glibc因為glibc比較大,busybox在寸土寸金的內嵌系統中運用比較多,所以會有這樣的要求。

編輯 ~/applets/applets.c , 將警告註解掉即可 (第 20-25 行)


...

/*

#if ENABLE_STATIC && defined(__GLIBC__) && !defined(__UCLIBC__)

#warning Static linking against glibc produces buggy executables

#warning (glibc does not cope well with ld --gc-sections).

#warning See sources.redhat.com/bugzilla/show_bug.cgi?id=3400

#warning Note that glibc is unsuitable for static linking anyway.

#warning If you still want to do it, remove -Wl,--gc-sections

#warning from top-level Makefile and remove this warning.

#endif

*/

...


接下來在進行編譯即可

$ make clean; make

驗證是否為 static linking


$ ldd ./busybox

not a dynamic executable


- make menuconfig 出現下列錯誤


...

In file included from scripts/kconfig/lxdialog/checklist.c:24:

scripts/kconfig/lxdialog/dialog.h:31:20: error: curses.h: No such file or directory

In file included from scripts/kconfig/lxdialog/checklist.c:24:

scripts/kconfig/lxdialog/dialog.h:128: error: syntax error before 'use_colors'

scripts/kconfig/lxdialog/dialog.h:128: warning: type defaults to 'int' in declaration of 'use_colors'

scripts/kconfig/lxdialog/dialog.h:128: warning: data definition has no type or storage class

scripts/kconfig/lxdialog/dialog.h:129: error: syntax error before 'use_shadow'

...

原因為缺少 ncurses devel 套件 (name "libncurses5-dev" in Ubuntu),安裝後即可

$ sudo apt-get install libncurses5-dev



阅读(2133) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~