交叉编译:GCC 忽略 --sysroot [英] Cross compilation: GCC ignores --sysroot

查看:83
本文介绍了交叉编译:GCC 忽略 --sysroot的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用 Linux Mint 64 位存储库中的 arm-linux-gnueabi-gcc 为诺基亚 N9 手机交叉编译程序(目前来自 libav 的 avconv).编译器的libc版本是2.15,手机是libc-2.10.1.它们在数学库中存在不兼容性,当我从 libav 编译和运行 avconv 程序时,这给了我一个段错误.

I'm trying to cross compile programs (currently avconv from libav) for a Nokia N9 phone using arm-linux-gnueabi-gcc from Linux Mint's 64-bit repository. The compiler's libc version is 2.15 and the phone has libc-2.10.1. They have an incompatibility in the math library, which gives me a segfault when I compile and run the avconv program from libav.

我需要针对旧的 libc 版本进行编译和链接,但我还没有设法让 --sysroot 选项起作用.

I'd need to compile and link against the older libc version, but I haven't managed to get the --sysroot option to work.

我做了一个小测试程序,避免重复配置和编译libav.

I made a small test program to avoid repeatedly configuring and compiling libav.

arm-linux-gnueabi-gcc --sysroot=/opt/CrossCompilation/NokiaN9/ -o output.sysroot hello.c
arm-linux-gnueabi-gcc -o output.nosysroot hello.c

这两个命令都创建了一个相同的输出文件.这是 hello.c 的样子:

Both commands create an identical output file. This is what hello.c looks like:

#include <stdio.h>
#include <math.h>

int main() {
    printf("Hello, World! Sin = %f\n", sin(0.6451));
}

最奇怪的是 gcc 完全忽略了 --sysroot 选项.如果我将一个不存在的目录传递给 sysroot,它仍然会产生完全相同的输出二进制文件:

The strangest part is that gcc completely ignores the --sysroot option. If I pass a nonexisting directory to sysroot, it still produces exactly the same output binary:

arm-linux-gnueabi-gcc --sysroot=/foo/bar -o output.foobar hello.c

它甚至没有抱怨任何错误.有什么问题?

It doesn't even complain about any errors. What's the problem?

推荐答案

因为我在阅读评论之前浪费了几天时间来搞这个,所以我要发布 无艺术噪音 的评论作为答案:

since I wasted a few days messing with this before reading the comments, I'm going to post artless noise's comments as an answer:

"用arm-linux-gnueabi-gcc -v运行编译器,查看--with-sysroot的值;这是编译器所在的目录用.如果你的机器上有这个目录(可能有不同的编译器),那么 --sysroot 可能不起作用[;如果你做not,请参阅 --with-sysroot 而不是看到 --with-libs,这意味着你的 gcc 是在没有 --sysroot 支持的情况下编译的."

"Run the compiler with arm-linux-gnueabi-gcc -v and look at the value of --with-sysroot; this is the directory the compiler was built with. If you have this directory present on your machine (maybe with a different compiler), then the --sysroot may not work[; and if you do not see --with-sysroot and instead see --with-libs, it] means your gcc is compiled without --sysroot support."

这篇关于交叉编译:GCC 忽略 --sysroot的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆