android busybox configure 交叉编译,ndk 交叉编译BusyBox心得。

cd ./busybox-1.26.2/

make android2_defconfig

makemenuconfig

n file included from include/libbb.h:13,

from coreutils/touch.c:82:

include/platform.h:483:6: warning: "__ANDROID_API__" is not defined

include/platform.h:486:8: warning: "__ANDROID_API__" is not defined

include/platform.h:492:6: warning: "__ANDROID_API__" is not defined

coreutils/touch.c: In function 'touch_main':

coreutils/touch.c:167: error: 'lutimes' undeclared (first use in this function)

coreutils/touch.c:167: error: (Each undeclared identifier is reported only once

coreutils/touch.c:167: error: for each function it appears in.)

make[1]: *** [coreutils/touch.o] 错误 1

make: *** [coreutils] 错误 2

platform.h  391 行定义:#define __ANDROID_API__ 8 后面编译看的眼花。

无意发现:'lutimes' undeclared 下面官网给的提示:

bool "Add support for -h"

//config:default y

//config:depends on TOUCH

//config:help

//config: Enable touch to have the -h option.

//config: This requires libc support for lutimes() function.

-h 默认开启。进make menuconfig 设置 coreutils touch -h去掉,完美解决。

不然关闭 touch不太好。

libbb/in_ether.c:12:26: error: net/ethernet.h: No such file or directory

miscutils/i2c_tools.c:66:27: error: linux/i2c-dev.h: No such file or directory

CC      miscutils/i2c_tools.o

miscutils/i2c_tools.c: In function 'i2c_smbus_write_i2c_block_data':

miscutils/i2c_tools.c:190: error: 'I2C_SMBUS_I2C_BLOCK_BROKEN' undeclared (first use in this function)

miscutils/i2c_tools.c:190: error: (Each undeclared identifier is reported only once

miscutils/i2c_tools.c:190: error: for each function it appears in.)

miscutils/i2c_tools.c: In function 'i2c_smbus_read_i2c_block_data':

miscutils/i2c_tools.c:225: error: 'I2C_SMBUS_I2C_BLOCK_BROKEN' undeclared (first use in this function)

miscutils/i2c_tools.c: In function 'check_funcs_test_end':

miscutils/i2c_tools.c:313: error: 'I2C_FUNC_SMBUS_PEC' undeclared (first use in this function)

miscutils/i2c_tools.c: At top level:

miscutils/i2c_tools.c:1055: error: 'I2C_FUNC_SMBUS_PEC' undeclared here (not in a function)

make[1]: *** [miscutils/i2c_tools.o] 错误 1

make: *** [miscutils] 错误 2

打开i2c_tools.c找系统头文件。

#include

#include

也没有linux/i2c.h

后面找头文件的方法和一样。

linux/i2c.h 定义:I2C_SMBUS_I2C_BLOCK_BROKEN和I2C_FUNC_SMBUS_PEC。

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

make[1]: *** [miscutils/nandwrite.o] 错误 1

make: *** [miscutils] 错误 2

mtd/mtd-abi.h 定义:MTD_FILE_MODE_RAW。

networking/libiproute/ipneigh.c:14:29: error: linux/neighbour.h: No such file or directory

一样。make 一堆错误修复。

networking/libiproute/iproute.c: In function 'print_route':

networking/libiproute/iproute.c:85: error: 'RTA_TABLE' undeclared (first use in this function)

networking/libiproute/iproute.c:85: error: (Each undeclared identifier is reported only once

networking/libiproute/iproute.c:85: error: for each function it appears in.)

networking/libiproute/iproute.c: In function 'iproute_modify':

networking/libiproute/iproute.c:437: error: 'RTA_TABLE' undeclared (first use in this function)

百度搜索:linux RTA_TABLE networking :linux/下

找到了http://blog..net/gt945/article/details/45315911

很快锁定目标。linux/rtnetlink.h

In file included from networking/libiproute/iproute.c:13:

networking/libiproute/ip_common.h:10:27: error: linux/if_addr.h: No such file or directory

networking/libiproute/ip_common.h:13:27: error: linux/if_link.h: No such file or directory

出来I早点多好,

networking/libiproute/ll_map.c: In function 'll_remember_index':

networking/libiproute/ll_map.c:47: error: 'IFLA_MAX' undeclared (first use in this function)

networking/libiproute/ll_map.c:47: error: (Each undeclared identifier is reported only once

networking/libiproute/ll_map.c:47: error: for each function it appears in.)

networking/libiproute/ll_map.c:56: warning: implicit declaration of function 'IFLA_RTA'

networking/libiproute/ll_map.c:56: warning: implicit declaration of function 'IFLA_PAYLOAD'

networking/libiproute/ll_map.c:56: warning: passing argument 3 of 'parse_rtattr' makes pointer from integer without a cast

networking/libiproute/libnetlink.h:45: note: expected 'struct rtattr *' but argument is of type 'int'

networking/libiproute/ll_map.c:57: error: 'IFLA_IFNAME' undeclared (first use in this function)

networking/libiproute/ll_map.c:75: error: 'IFLA_ADDRESS' undeclared (first use in this function)

networking/libiproute/ll_map.c:47: warning: unused variable 'tb'

make[1]: *** [networking/libiproute/ll_map.o] 错误 1

从网络入手:http://blog..net/romainxie/article/details/8300443

linux/nfnetlink.h

util-linux/blkdiscard.c: In function 'blkdiscard_main':

util-linux/blkdiscard.c:71: error: 'BLKSECDISCARD' undeclared (first use in this function)

util-linux/blkdiscard.c:71: error: (Each undeclared identifier is reported only once

util-linux/blkdiscard.c:71: error: for each function it appears in.)

util-linux/blkdiscard.c:71: error: 'BLKDISCARD' undeclared (first use in this function)

make[1]: *** [util-linux/blkdiscard.o] 错误 1

make: *** [util-linux] 错误 2

linux/fs.h

util-linux/fstrim.c: In function 'fstrim_main':

util-linux/fstrim.c:53: error: storage size of 'range' isn't known

util-linux/fstrim.c:91: error: invalid application of 'sizeof' to incomplete type 'struct fstrim_range'

util-linux/fstrim.c:91: error: array type has incomplete element type

util-linux/fstrim.c:91: error: invalid application of 'sizeof' to incomplete type 'struct fstrim_range'

util-linux/fstrim.c:91: error: invalid application of 'sizeof' to incomplete type 'struct fstrim_range'

util-linux/fstrim.c:53: warning: unused variable 'range'

make[1]: *** [util-linux/fstrim.o] 错误 1

换这个:linux/fs.h解决。

util-linux/setarch.c:57:29: error: sys/personality.h: No such file or directory

util-linux/setarch.c: In function 'setarch_main':

util-linux/setarch.c:82: error: 'PER_LINUX' undeclared (first use in this function)

util-linux/setarch.c:82: error: (Each undeclared identifier is reported only once

util-linux/setarch.c:82: error: for each function it appears in.)

util-linux/setarch.c:86: error: 'PER_LINUX32' undeclared (first use in this function)

util-linux/setarch.c:95: warning: implicit declaration of function 'personality'

make[1]: *** [util-linux/setarch.o] 错误 1

make: *** [util-linux] 错误 2

util-linux/swaponoff.c: In function 'swap_enable_disable':

util-linux/swaponoff.c:152: warning: implicit declaration of function 'swapoff'

util-linux/swaponoff.c:166: warning: implicit declaration of function 'swapon'

util-linux/swaponoff.c: In function 'do_em_all_in_fstab':

util-linux/swaponoff.c:237: warning: implicit declaration of function 'hasmntopt'

util-linux/swaponoff.c:237: error: 'MNTOPT_NOAUTO' undeclared (first use in this function)

util-linux/swaponoff.c:237: error: (Each undeclared identifier is reported only once

util-linux/swaponoff.c:237: error: for each function it appears in.)

util-linux/swaponoff.c:242: warning: initialization makes pointer from integer without a cast

util-linux/swaponoff.c:250: warning: initialization makes pointer from integer without a cast

util-linux/swaponoff.c:262: warning: implicit declaration of function 'endmntent'

make[1]: *** [util-linux/swaponoff.o] 错误 1

make: *** [util-linux] 错误 2

linux pc 头文件: mntent.h   定义:MNTOPT_NOAUTO

#define MNTOPT_NOAUTO"noauto"/* Do not auto mount.  */

或者 加进 swaponoff.c里。

到这里基本接近尾声了。

LINK    busybox_unstripped

Trying libraries: m

Failed: -Wl,--start-group  -lm  -Wl,--end-group

Output of:

/usr/gcc/bin/arm-linux-androideabi-gcc -Wall -Wshadow -Wwrite-strings -Wundef -Wstrict-prototypes -Wunused -Wunused-parameter -Wunused-function -Wunused-value -Wmissing-prototypes -Wmissing-declarations -Wno-format-security -Wdeclaration-after-statement -Wold-style-definition

-fno-builtin-strlen -finline-limit=0 -fomit-frame-pointer -ffunction-sections -fdata-sections -fno-guess-branch-probability -funsigned-char -static-libgcc -falign-functions=1 -falign-jumps=1 -falign-labels=1 -falign-loops=1 -fno-unwind-tables -fno-asynchronous-unwind-tables

-fno-builtin-printf -Os -o busybox_unstripped -Wl,--sort-common -Wl,--sort-section,alignment -Wl,--gc-sections -Wl,--start-group applets/built-in.o archival/lib.a archival/libarchive/lib.a console-tools/lib.a coreutils/lib.a coreutils/libcoreutils/lib.a debianutils/lib.a

e2fsprogs/lib.a editors/lib.a findutils/lib.a init/lib.a libbb/lib.a libpwdgrp/lib.a loginutils/lib.a mailutils/lib.a miscutils/lib.a modutils/lib.a networking/lib.a networking/libiproute/lib.a networking/udhcp/lib.a printutils/lib.a procps/lib.a runit/lib.a

selinux/lib.a shell/lib.a sysklogd/lib.a util-linux/lib.a util-linux/volume_id/lib.a archival/built-in.o archival/libarchive/built-in.o console-tools/built-in.o coreutils/built-in.o coreutils/libcoreutils/built-in.o debianutils/built-in.o e2fsprogs/built-in.o

editors/built-in.o findutils/built-in.o init/built-in.o libbb/built-in.o libpwdgrp/built-in.o loginutils/built-in.o mailutils/built-in.o miscutils/built-in.o modutils/built-in.o networking/built-in.o networking/libiproute/built-in.o networking/udhcp/built-in.o

printutils/built-in.o procps/built-in.o runit/built-in.o selinux/built-in.o shell/built-in.o sysklogd/built-in.o util-linux/built-in.o util-linux/volume_id/built-in.o -Wl,--end-group -Wl,--start-group -lm -Wl,--end-group

==========

util-linux/lib.a(nsenter.o): In function `nsenter_main':

nsenter.c:(.text.nsenter_main+0x1a4): undefined reference to `setns'

util-linux/lib.a(setarch.o): In function `setarch_main':

setarch.c:(.text.setarch_main+0x4c): undefined reference to `personality'

util-linux/lib.a(swaponoff.o): In function `swap_enable_disable':

swaponoff.c:(.text.swap_enable_disable+0x20): undefined reference to `swapoff'

swaponoff.c:(.text.swap_enable_disable+0x80): undefined reference to `swapon'

util-linux/lib.a(swaponoff.o): In function `swap_on_off_main':

swaponoff.c:(.text.swap_on_off_main+0x174): undefined reference to `hasmntopt'

swaponoff.c:(.text.swap_on_off_main+0x194): undefined reference to `hasmntopt'

coreutils/lib.a(sync.o): In function `sync_main':

sync.c:(.text.sync_main+0x8c): undefined reference to `syncfs'

libbb/lib.a(find_mount_point.o): In function `find_mount_point':

find_mount_point.c:(.text.find_mount_point+0x54): undefined reference to `setmntent'

find_mount_point.c:(.text.find_mount_point+0x114): undefined reference to `endmntent'

libbb/lib.a(pw_encrypt.o): In function `pw_encrypt':

pw_encrypt.c:(.text.pw_encrypt+0x4): undefined reference to `crypt'

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"

make: *** [busybox_unstripped] 错误 1

//error: undefined reference to 'setns'

//error: undefined reference to 'personality'

//error: undefined reference to 'swapoff'

//error: undefined reference to 'swapon'

error: undefined reference to 'hasmntopt'

//error: undefined reference to 'syncfs'

error: undefined reference to 'setmntent'

error: undefined reference to 'endmntent'

error: undefined reference to 'crypt'

问题:直接使用syscal:

#include

# include

__BEGIN_DECLS

int syscall(int number, ...);

__END_DECLS

非常简单。

例子:

err =syscall(__NR_swapoff,device);

有几个参数,就几个。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
对于busybox交叉编译,您可以按照以下步骤进行操作: 1. 获取交叉编译工具链:您需要首先获取与目标平台相匹配的交叉编译工具链,以便在本机上进行编译。您可以从目标平台的供应商或社区获取这个工具链。 2. 下载busybox源代码:您可以从busybox的官方网站(https://busybox.net/downloads/)上下载最新的稳定版本的源代码。 3. 设置环境变量:将交叉编译工具链添加到您的环境变量中,以便系统能够找到它们。例如,您可以将工具链的路径添加到`PATH`变量中。 4. 配置busybox:在命令行中进入busybox源代码目录,并运行`make menuconfig`命令来配置busybox。这将打开一个文本菜单界面,您可以在其中选择要包含在busybox中的功能。 5. 设置目标平台:在配置菜单中设置目标平台的体系结构和编译选项。这些选项将取决于您的目标平台和交叉编译工具链。 6. 编译busybox:运行`make`命令来开始编译busybox。这将使用交叉编译工具链在本机上生成目标平台的可执行文件。 7. 安装busybox:运行`make install`命令来安装busybox。这将把生成的可执行文件复制到指定的安装目录中。 完成上述步骤后,您将得到一个交叉编译后的busybox可执行文件,可以将其部署到目标平台上使用。请注意,具体的步骤可能会因您使用的交叉编译工具链和目标平台而有所不同。因此,在进行交叉编译之前,请确保您已经阅读并理解了相应工具链和平台的文档和指南。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值