交叉编译:GCC忽略--sysroot

问题描述:

我试图交叉编译程序(目前从libav avconv)使用来自Linux Mint的64位库臂Linux的gnueabi-GCC一个诺基亚N9手机。编译器的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 如下:

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

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

最奇怪的是,海湾合作委员会完全忽略了 - 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:

运行与编译器臂Linux的gnueabi-GCC -v 看看的价值 - 与-SYSROOT ;这是编译器内置的目录如果您的机器上这个目录present(也许用不同的编译器),那么--sysroot可能无法正常工作[。如果你这样做的看到 - 与-SYSROOT ,而是看 - 与-库,它]意味着你的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."