【问题标题】:Failure on cross compiling busybox交叉编译busybox失败
【发布时间】:2018-08-08 02:51:01
【问题描述】:

我正在尝试为我的嵌入式 Linux 设备交叉编译busy box 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,但它需要一些我不知道的有关处理器的信息(例如字节序、详细版本等),这是一个黑盒设备,我只在其上开发应用程序,我拥有的全部信息是它运行BCM5892,一个来自 Broadcom 的 ARM11 安全处理器。它在 kenel V 2.6 和 arm-brcm-linux-gnueabi V4.4.2 编译器上运行,我也正确设置了 sysroot 和交叉编译器前缀,但我怎么知道我是哪个版本的 libc米使用?

【问题讨论】:

  • 如果您的嵌入式 Linux 设备使用的是旧版本的 uclibc,它可能没有 setnssyncfs
  • 我用的是内核V2.6和arm-brcm-linux-gnueabi V4.4.2,你的意思是编译过程中使用了uclibc吗?如何识别它的版本?
  • 附加有关您的环境(环境变量)、使用的库版本和编译器(和使用的 libc)的信息。我可以通过 buildroot 构建它的好方法,这肯定会修复您可以构建的许多问题。
  • @AlejandroVisiedo 谢谢你的回答,我也尝试 buildroot,但它需要一些关于处理器的信息(例如字节序,详细版本等),我不知道,这是一个黑盒设备和我只在上面开发应用程序,我掌握的全部信息是它在 BCM5892 上运行,这是一个来自 broadcom 的 ARM11 安全处理器。它在 kenel V 2.6 和 arm-brcm-linux-gnueabi V4.4.2 编译器上运行,我还正确设置了 sysroot 和交叉编译器前缀,但我怎么知道我使用的是哪个版本的 libc?

标签: c cross-compiling embedded-linux busybox


【解决方案1】:

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

[*] sync (3.8 kb)                                                                                                              
[ ]   Enable -d and -f flags (requires syncfs(2) in libc) 

取消更新版本的 uclibc (> 0.9.33) 可以允许启用该选项。

【讨论】:

    【解决方案2】:

    您可以通过检查此链接目标的名称来检测您的 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
    

    这表示 glibc 版本为 2.10.2。 但要确保您也可以这样做:

    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 Kernel 2.6.32.59 编译busybox-1.30.1 时遇到了类似的问题,我不得不阻止 nsenter.c 和 sync.c 被 Makefile 编译。

    因此,在您的情况下,您可以尝试更改 .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
    

    希望这会有所帮助。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-04-12
      • 2015-06-11
      • 2014-04-27
      • 2016-03-09
      • 1970-01-01
      相关资源
      最近更新 更多