如何配置busybox 才能添加上格式化命令

如何配置busybox 才能添加上格式化命令,第1张

1.USE_NEWCMD(APPLET(newcmd, newcmd_main, _BB_DIR_USER_BIN, _BB_SUID_NEVER))

此语句,在编译的时候会报出 USE_NEWCMD 未定义!

故使用源码中的类似语句 APPLET(newcmd, newcmd_main, _BB_DIR_USER_BIN, _BB_SUID_NEVER) 替代之,编译通过

2.但是 在此时测试命令的时候并没有得到上文给出的结果,而是提示:

"#./busybox newcmd

newcmd: applet not found "

# ./newcmd 11

11: applet not found

1. 创建并启动容器 docker create命令来创建容器 $ docker create -it --name=busybox busybox 1 容器启动有两种方式: 使用docker start命令基于

2. 终止容器 容器停止用docker stop 命令。格式为: docker stop [-t]|–time[=10]. 该命令首先会向运行中的容器发送SIGTERM信号,如果

3. 进入容器 处于运行状态的容器可以通过docker

【具体步骤】:

1) 下载 busybox 源代码,并解包

$ wget -c http //www点busybox点net/downloads/busybox-1.7.0.tar.bz2

$ tar jxvf busybox-1.7.0.tar.bz2

2) 下载交叉编译工具,并安装

我下载的是: arm-2009q1-161-arm-none-eabi.bin

说明:要正确设置好 PATH 变量。

例如将 “ 你的目录 ”/CodeSourcery/Sourcery_G++_Lite/bin 加到 PATH 路径中。

3 )进入到 busybox 解压后的源文件目录中,修改 Makefile

将第 176 行改为:

CROSS_COMPILE ?=arm-none-linux-gnueabi-

4 )进行编译选项配置

a 、

$ make menuconfig

Busybox Settings --->

Build Options --->

[*] Build BusyBox as a static binary(no shared libs)

说明:这个选项一定要选,这样才能把 busybox 编译成静态链接的可执行文件,运行时可以独立于其他库。

b 、

Installation Options --->

[*] Don't use /usr

说明:这个也一定要选,否则 make install 后, busybox 将安装在原来系统的 /usr 下,将你原有的命令都覆盖了!

5 )配置好后可以编译了,执行如下命令:

$ make

发现没过多久,就报错了,晕,错误内容如下:

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

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

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

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

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

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

applets/applets.c:26:2: error: #error Aborting compilation.

make[1]: *** [applets/applets.o] 错误 1

make: *** [applets] 错误 2

看到它给出了提示,说 glibc 库不适和用来静态编译,最后给出解决方案就是将 applets/applets.c 中这部分内容给去掉,也就是 19-27 行。

然后再 make 进行编译。

不多久又报错了,看看具体错误:

 

 .../compal/CodeSourcery/Sourcery_G++_Lite/bin/../arm-none-linux-gnueabi/libc/usr/include/linux/netfilter.h:56:17:

error: field 'in' has incomplete type

.../CodeSourcery

/Sourcery_G++_Lite/bin/../arm-none-linux-gnueabi/libc/usr/include/linux/netfilter.h:57:18:

error: field 'in6' has incomplete type

ipsvd/tcpudp.c: In function 'tcpudpsvd_main':

ipsvd/tcpudp.c:314:10: warning: ignoring return value of 'write', declared with attribute warn_unused_result

make[1]: *** [ipsvd/tcpudp.o] 错误 1

make: *** [ipsvd] 错误 2

看到说在我们下载的交叉编译库中有个头文件中的 in 及 in6 类型不对,解决的办法就是:

在 .../arm-none-linux-gnueabi/libc/usr/include/linux/netfilter.h 的开头

添加缺少的头文件:

#include <netinet/in.h>

然后再进行编译。(这次可以安全到最后了,呵呵)

结束后会在当前目录下看到 busybox 这个可执行文件。

6 )编译步骤已完成,下面就将 busybox 这个可执行文件放到 Android 模拟器下去

$ adb push busybox /system/xbin

说明:若是出现什么 read-only file system 等等之类,执行如下命令即可:

$ adb remount

要是老是不行,那就重新启动 adb

$ adb kill-server

$ adb start-server

要是碰到什么内存不足等等,那原因就是你的那个 Android 模拟器是用 Eclipse 打开的。解决办法就是,手动启动你的 Android emulator 模拟器,具体如下:

$ android list avd # 注释:列出你所有的模拟器

$ emulator -avd your_emulator_name -partition-size 256

注意:最好放在 /system/xbin 下面,这样当你在模拟器里使用 busybox 时不需要指定绝对路径了,否则的话谁都会疯掉嘛,呵呵。

7 )输入 adb shell 进入终端,执行看看

# busybox --help

BusyBox v1.7.0 (2011-04-22 20:53:21 CST) multi-call binary

Copyright (C) 1998-2006 Erik Andersen, Rob Landley, and others.

Licensed under GPLv2. See source distribution for full notice.


欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/bake/11213652.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-05-14
下一篇 2023-05-14

发表评论

登录后才能评论

评论列表(0条)

保存