编译busybox-1.26
无    2017-02-28 21:26:39    388    0    0
tianwaifeixian

1.修改 Makefile
找到以下2处修改为
ARCH ?= arm
CROSS_COMPILE ?= arm-linux-

2. make menuconfig

(1)Tab键自动补齐功能(本版本默认以选中)
BusyBox Settings-->BusyBox Liarary Tuning-->Tab completion;
(2)将BusyBox编译为静态链接
BusyBox Settings-->Build Options-->Build Busybox as a static binary(no shared libs)
(3)如果使用不同的交叉编译工具,需指定编译工具的路径,(要手动添加)
这个配置项为:
Busybox Settings-->Build Options-->Cross Compiler prefix;
(4)init程序应该读取配置文件/etc/inittab.(本版本默认已选中)
这个配置项为
Init Utilities-->Support reading an inittab file

保存退出:
scripts/kconfig/mconf Config.in
#
# using defaults found in /dev/null
#


*** End of configuration.
*** Execute 'make' to build the project or try 'make help'.

>make​
>make
miscutils/nandwrite.c: In function 'nandwrite_main':
miscutils/nandwrite.c:151:3: error: 'MTD_FILE_MODE_RAW' undeclared (first use in this function)
miscutils/nandwrite.c:151:3: note: each undeclared identifier is reported only once 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:745: recipe for targ​

在:Miscellaneous Utilities里面找到
nandwrite nanddump
去掉前面的选中

继续make

util-linux/blkdiscard.c: In function 'blkdiscard_main':
util-linux/blkdiscard.c:71:26: error: 'BLKSECDISCARD' undeclared (first use in this function)
util-linux/blkdiscard.c:71:26: note: each undeclared identifier is reported only once 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:745: recipe for target 'util-linux' failed
make: *** [util-linux] Error 2

到这里看到了不同的做法 我大概看了一下是编译器的问题

交叉编译工具在制作过程中没有相关的选项编译进去导致了各种的头文件没有

换了最新的编译器

>arm-linux-gnueabihf-gcc -v
Using built-in specs.
COLLECT_GCC=arm-linux-gnueabihf-gcc
COLLECT_LTO_WRAPPER=/opt/arm-gcc/gcc-linaro-6.2.1-2016.11-x86_64_arm-linux-gnueabihf/bin/../libexec/gcc/arm-linux-gnueabihf/6.2.1/lto-wrapper
Target: arm-linux-gnueabihf
Configured with: /home/tcwg-buildslave/workspace/tcwg-make-release/label/docker-trusty-amd64-tcwg-build/target/arm-linux-gnueabihf/snapshots/gcc-linaro-6.2-2016.11/configure SHELL=/bin/bash --with-mpc=/home/tcwg-buildslave/workspace/tcwg-make-release/label/docker-trusty-amd64-tcwg-build/target/arm-linux-gnueabihf/_build/builds/destdir/x86_64-unknown-linux-gnu --with-mpfr=/home/tcwg-buildslave/workspace/tcwg-make-release/label/docker-trusty-amd64-tcwg-build/target/arm-linux-gnueabihf/_build/builds/destdir/x86_64-unknown-linux-gnu --with-gmp=/home/tcwg-buildslave/workspace/tcwg-make-release/label/docker-trusty-amd64-tcwg-build/target/arm-linux-gnueabihf/_build/builds/destdir/x86_64-unknown-linux-gnu --with-gnu-as --with-gnu-ld --disable-libstdcxx-pch --disable-libmudflap --with-cloog=no --with-ppl=no --with-isl=no --disable-nls --enable-c99 --enable-gnu-indirect-function --disable-multilib --with-tune=cortex-a9 --with-arch=armv7-a --with-fpu=vfpv3-d16 --with-float=hard --with-mode=thumb --enable-multiarch --with-build-sysroot=/home/tcwg-buildslave/workspace/tcwg-make-release/label/docker-trusty-amd64-tcwg-build/target/arm-linux-gnueabihf/_build/sysroots/arm-linux-gnueabihf --enable-lto --enable-linker-build-id --enable-long-long --enable-shared --with-sysroot=/home/tcwg-buildslave/workspace/tcwg-make-release/label/docker-trusty-amd64-tcwg-build/target/arm-linux-gnueabihf/_build/builds/destdir/x86_64-unknown-linux-gnu/arm-linux-gnueabihf/libc --enable-languages=c,c++,fortran,lto --enable-checking=release --disable-bootstrap --build=x86_64-unknown-linux-gnu --host=x86_64-unknown-linux-gnu --target=arm-linux-gnueabihf --prefix=/home/tcwg-buildslave/workspace/tcwg-make-release/label/docker-trusty-amd64-tcwg-build/target/arm-linux-gnueabihf/_build/builds/destdir/x86_64-unknown-linux-gnu
Thread model: posix
gcc version 6.2.1 20161016 (Linaro GCC 6.2-2016.11) ​

继续make

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

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:720: recipe for target 'busybox_unstripped' failed
make: *** [busybox_unstripped] Error 1
make menuconfig
Coreutils--->sync​

选项去掉
重新make编译通过,生成了busybox可执行文件。​

Static linking against glibc, can't use --gc-sections
Trying libraries: crypt m
 Library crypt is not needed, excluding it
 Library m is needed, can't exclude it (yet)
Final link with: m
  DOC     busybox.pod
  DOC     BusyBox.txt
  DOC     busybox.1
  DOC     BusyBox.html
-rw-r--r--  1 x users 1696864 2月  28 21:17 busybox_unstripped.map
-rwxr-xr-x  1 x users 2295755 2月  28 21:17 busybox_unstripped
-rw-r--r--  1 x users  104316 2月  28 21:17 busybox_unstripped.out
drwxr-xr-x  3 x users    4096 2月  28 21:17 include
-rwxr-xr-x  1 x users 1875676 2月  28 21:17 busybox


安装:

>make CONFIG_PREFIX=/var/nfs_share/first_fs/ install​
--------------------------------------------------
You will probably need to make your busybox binary
setuid root to ensure all configured applets will
work properly.
--------------------------------------------------​
>ls -l /var/nfs_share/first_fs/​


总用量 8
drwxr-xr-x 2 xuan users 4096 3月 1 09:09 bin
lrwxrwxrwx 1 xuan users 11 3月 1 09:09 linuxrc -> bin/busybox
drwxr-xr-x 2 xuan users 4096 3月 1 09:09 sbin
drwxr-xr-x 4 xuan users 29 3月 1 09:09 usr​
>sudo chown root:root -R /var/nfs_share/first_fs/​

>ls -l /var/nfs_share/first_fs/
总用量 8
drwxr-xr-x 2 root root 4096 3月 1 09:09 bin
lrwxrwxrwx 1 root root 11 3月 1 09:09 linuxrc -> bin/busybox
drwxr-xr-x 2 root root 4096 3月 1 09:09 sbin
drwxr-xr-x 4 root root 29 3月 1 09:09 usr





参考:http://www.cnblogs.com/softhal/p/5769121.html

上一篇: 制作根文件系统

下一篇: 移植4.1.36内核

388 人读过
立即登录, 发表评论.
没有帐号? 立即注册
0 条评论
文档导航