交叉编译busybox失败

时间:2018-02-28 09:21:08

标签: c cross-compiling embedded-linux busybox

我试图为我的嵌入式Linux设备交叉编译繁忙的盒子V 1.27.2。我将共享库构建和交叉编译器前缀和Sysroot设置为我的编译器目标。尝试编译大多数库文件后编译器无法链接它们。我收到了:

Trying libraries: crypt m
Failed: -Wl,--start-group  -lcrypt -lm  -Wl,--end-group
Output of:
/home/bluebird/brcm-armtools-64bit/tools/le_arm11_external_20090306/bin/arm-brcm-linux-gnueabi-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 -fpic -fvisibility=hidden --sysroot=/home/bluebird/brcm-armtools-64bit/tools/le_arm11_external_20090306/sysroot -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 -lcrypt -lm -Wl,--end-group
==========
coreutils/lib.a(mktemp.o): In function `mktemp_main':
mktemp.c:(.text.mktemp_main+0xbc): warning: the use of `mktemp' is dangerous, better use `mkstemp'
coreutils/lib.a(touch.o): In function `touch_main':
touch.c:(.text.touch_main+0x1f4): warning: warning: lutimes is not implemented and will always fail
util-linux/lib.a(nsenter.o): In function `nsenter_main':
nsenter.c:(.text.nsenter_main+0x1b4): undefined reference to `setns'
coreutils/lib.a(sync.o): In function `sync_main':
sync.c:(.text.sync_main+0x9c): 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"
make: *** [busybox_unstripped] Error 1

我的sysroot目录中也有libm.so。

修改 我也尝试buildroot,但它需要一些关于处理器的信息(例如endian,详细版本等),我不知道,这是一个黑盒子设备,我只在它上面开发应用程序,我有的总信息是它运行BCM5892是一个来自broadcom.it的ARM11安全处理器,运行在kenel V 2.6和arm-brcm-linux-gnueabi V4.4.2编译器上,我也正确设置了sysroot和交叉编译器前缀,但我怎么知道哪个版本的libc我# 39; m使用?

2 个答案:

答案 0 :(得分:0)

您可以通过检查以下链接目标的名称来检测glibc版本:

root@debianxc:/usr/src/busybox# file /opt/STM/STLinux-2.4/devkit/sh4/target/lib/libc.so.6
/opt/STM/STLinux-2.4/devkit/sh4/target/lib/libc.so.6: symbolic link to libc-2.10.2.so
root@debianxc:/usr/src/busybox# file /opt/STM/STLinux-2.4/devkit/sh4/target/lib/ld-linux.so.2
/opt/STM/STLinux-2.4/devkit/sh4/target/lib/ld-linux.so.2: symbolic link to ld-2.10.2.so

这表示2.1.2的glibc版本。 但是要确保您也可以这样做:

root@debianxc:/usr/src/busybox# strings /opt/STM/STLinux-2.4/devkit/sh4/target/lib/libc.so.6 | grep '^GLIBC_' | sort | uniq
GLIBC_2.10
GLIBC_2.2
GLIBC_2.2.1
GLIBC_2.2.2
GLIBC_2.2.3
GLIBC_2.2.4
GLIBC_2.2.6
GLIBC_2.3
GLIBC_2.3.2
GLIBC_2.3.3
GLIBC_2.3.4
GLIBC_2.4
GLIBC_2.5
GLIBC_2.6
GLIBC_2.7
GLIBC_2.8
GLIBC_2.9
GLIBC_PRIVATE
root@debianxc:/usr/src/busybox# strings /opt/STM/STLinux-2.4/devkit/sh4/target/lib/ld-linux.so.2 | grep '^GLIBC_' | sort | uniq
GLIBC_2.2
GLIBC_2.3
GLIBC_2.4
GLIBC_PRIVATE

当我为SH4内核2.6.32.59编译busybox-1.30.1时遇到类似的问题,我不得不防止Makefile编译nsenter.c和sync.c。

因此,您可以尝试更改.config文件。

root@debianxc:/usr/src/busybox# diff -d .config_from_defconfig .config
4c4
< # Wed Apr  3 20:04:24 2019
---
> # Wed Apr  3 20:09:45 2019
273c273
< CONFIG_MKTEMP=y
---
> # CONFIG_MKTEMP is not set
304,305c304,305
< CONFIG_SYNC=y
< CONFIG_FEATURE_SYNC_FANCY=y
---
> # CONFIG_SYNC is not set
> # CONFIG_FEATURE_SYNC_FANCY is not set
316,318c316,318
< CONFIG_TOUCH=y
< CONFIG_FEATURE_TOUCH_NODEREF=y
< CONFIG_FEATURE_TOUCH_SUSV3=y
---
> # CONFIG_TOUCH is not set
> # CONFIG_FEATURE_TOUCH_NODEREF is not set
> # CONFIG_FEATURE_TOUCH_SUSV3 is not set
667c667
< CONFIG_NSENTER=y
---
> # CONFIG_NSENTER is not set

这些是您可以遵循的步骤:

#Backup your .config
cp .config .config.backup

#Create a new config with this sed command. You will see its effect by the follow-up diff command below...
sed -e '/^\(CONFIG_\)\(\(MKTEMP\)\|\(TOUCH\)\|\(NSENTER\)\|\(SYNC\)\)=.*$/s/^\([^=]*\)=.*$/# \1 is not set/' .config >.newconfig

#With this diff output you will see its effect
diff -d .config .newconfig

#Overwrite current .config with .newconfig
cp .newconfig .config

#Now run make oldconfig, because some disablings need auto-disablings of other depending configs, too...
make oldconfig

#See the effect ...
diff -d .config.old .config

#make clean before re-compiling
make clean

#make busybox with cross-compiler
make CROSS_COMPILE=sh4-linux-

#Your new busybox is located in your working direktory

#Optionally invoke make install to create dir tree with symlinks
make CROSS_COMPILE=sh4-linux- install

#Tree's name is _install

希望这会有所帮助。

答案 1 :(得分:0)

打开 busybox menuconfig 并禁用“启用 -d 和 -f 标志”

message.member.guild.members.cache.size

使用更新的 uclibc (> 0.9.33) 版本可以启用该选项。