Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/linux/26.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Linux Can';t交叉编译时通过./configure访问Buildroot临时库。它在测试编译时失败。_Linux_Sdl 2_Buildroot - Fatal编程技术网

Linux Can';t交叉编译时通过./configure访问Buildroot临时库。它在测试编译时失败。

Linux Can';t交叉编译时通过./configure访问Buildroot临时库。它在测试编译时失败。,linux,sdl-2,buildroot,Linux,Sdl 2,Buildroot,案例1 armlinuxgcc-vhello.c==>工作正常 案例2 armlinux gcc-v-L/home/peter/igep2015/09Buildroot/buildroot-2016.02-TRY5/output/staging/usr/lib hello.c=>不工作 错误:ld.bfd:找不到/usr/lib/libc_nonshared.a 错误:ld.bfd:找不到/lib/ld linux.so.3 案例3 arm linux gcc-v--sysroot=/home/

案例1 armlinuxgcc-vhello.c==>工作正常

案例2
armlinux gcc-v-L/home/peter/igep2015/09Buildroot/buildroot-2016.02-TRY5/output/staging/usr/lib hello.c=>不工作 错误:ld.bfd:找不到/usr/lib/libc_nonshared.a 错误:ld.bfd:找不到/lib/ld linux.so.3

案例3 arm linux gcc-v--sysroot=/home/peter/igep2015/09Buildroot/buildroot-2016.02-TRY5/output/host/usr/armeb-buildroot-linux-gnueabi/sysroot/hello.c=>WORKS 但是说它忽略了sysroot,因为它找不到/usr/include,所以类似于case#1注意buildroot staging符号链接到buildroot sysroot

相应的libc库位于:
/usr/local/xtools/arm unknown linux gnueabi/arm unknown linux gnueabi/sysroot/usr/lib/:/usr/local/xtools/arm unknown linux gnueabi/arm unknown linux gnueabi/sysroot/lib/

/home/peter/igep2015/09Buildroot/buildroot-2016.02-TRY5/output/host/usr/armeb buildroot-linux-gnueabi/sysroot/usr/lib:/home/peter/igep2015/09Buildroot/buildroot-2016.02-TRY5/output/host/usr/armeb-buildroot-linux-gnueabi/sysroot/lib/

/armlinux和Buildroot库似乎是相同的。cross工具用于构建Buildroot

问题是:当我链接到Buildroot暂存库时,为什么arm linux gcc会失败。出现这个问题是因为自动工具./configure使用-L构建根目录失败。但是我需要-L来访问Buildroot中的libSDL2、libfreetype等,以便交叉编译SDL2\u ttf


注意:我正在使用(crosstool NG 1.21.0)5.1.0。

这是一个非常奇怪的问题/lib/works但/usr/lib不起作用

具体地说

arm-linux-gcc -L/home/peter/igep2015/09Buildroot/buildroot-2016.02-TRY5/output/host/usr/armb-buildroot-linux-gnueabi/sysroot/lib  hello.c
……工作

但是

arm-linux-gcc -L/home/peter/igep2015/09Buildroot/buildroot-2016.02-TRY5/output/host/usr/armb-buildroot-linux-gnueabi/sysroot/usr/lib  hello.c
……失败了

解决了的: 注意:要解决这些链接器问题,请使用命令

arm-linux-gcc -Wl,--verbose -L/home/peter/igep2015/09Buildroot/buildroot- 2016.02-TRY5/output/staging/usr/lib hello.c
案例2的原因

arm-linux-gcc -Wl,--verbose -L/home/peter/igep2015/09Buildroot/buildroot-2016.02-TRY5/output/staging/usr/lib hello.c
没用的是-我。。。首先搜索,然后在Buildroot中找到libc.so(包含依赖于gcc sysroot的用于查找libc_nonshared.a等的链接器脚本命令),然后才能在gcc库中正确找到

案例1和案例3的原因

arm-linux-gcc -Wl,--verbose -L/home/peter/igep2015/09Buildroot/buildroot-2016.02-TRY5/output/staging/lib hello.c  AND   
arm-linux-gcc -Wl,--verbose hello.c
这两项工作都是没有找到包含依赖于gcc sysroot的链接器脚本命令的库。因此,在gcc库中可以找到合适的链接器脚本命令libc.so

阅读第二个答案

您将看到gcc链接器脚本命令组的行为如下:
如果
-1-脚本位于sysroot前缀内,并且
-2-配置了sysroot前缀,并且
-3-文件名以/
否则,组仅在当前目录中查找

要确认正在使用的sysroot前缀

arm-linux-gcc -print-sysroot
/usr/local/xtools/arm-unknown-linux-gnueabi/arm-unknown-linux-gnueabi/sysroot
有几种假定的方法可以解决案例2的问题

解决方案#1 从Buildroot中删除libc.so。然后链接器将继续搜索并在gcc sysroot中正确找到libc.so

rm /home/peter/igep2015/09Buildroot/buildroot-2016.02-TRY5/output/staging/usr/lib/libc.so
解决方案#2 将gcc sysroot更改为Buildroot,如案例3所示

解决方案#3 更改Buildroot的libc中的链接器脚本命令,如下所示:

发件人:

致:


只是不要做任何你正在做的事情。Buildroot交叉编译器配置为自动搜索$(STAGING_DIR)/usr/lib中的库和$(STAGING_DIR)/usr/include中的头。您所描述的所有黑客都不需要。

不幸的是,我使用的是Buildroot外部的交叉编译器-crosstool-ng-1.21.0我测试了Thomas的建议,crosstool-ng-1.21.0似乎无法识别环境变量$STAGING\u DIR…除非我在ct ng配置中遗漏了一些内容。
/* GNU ld script
    Use the shared library, but some functions are only in
   the static library, so try that secondarily.  */
OUTPUT_FORMAT(elf32-littlearm)
GROUP ( /lib/libc.so.6 /usr/lib/libc_nonshared.a  AS_NEEDED ( /lib/ld-linux.so.3 ) )
/* GNU ld script
   Use the shared library, but some functions are only in
   the static library, so try that secondarily.  */
OUTPUT_FORMAT(elf32-littlearm)
GROUP ( ../../lib/libc.so.6 libc_nonshared.a  AS_NEEDED ( ../../lib/ld-linux.so.3 ) )