20

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.

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

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

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));
}

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?

trololo
  • 369
  • 1
  • 3
  • 4
  • 10
    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. What is the `gcc` version? – artless noise Jul 11 '13 at 21:19
  • There is no "--with-sysroot" defined. gcc is version 4.6.3 – trololo Jul 11 '13 at 21:45
  • But instead 'grep /usr/arm' finds "--with-gxx-include-dir=/usr/arm-linux-gnueabi/include/c++/4.6.3", "--includedir=/usr/arm-linux-gnueabi/include", "--with-headers=/usr/arm-linux-gnueabi/include", and "--with-libs=/usr/arm-linux-gnueabi/lib". – trololo Jul 11 '13 at 21:50
  • 8
    `--with-libs` means your `gcc` is compiled without `--sysroot` support. – artless noise Jul 12 '13 at 15:16

1 Answers1

10

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:

"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."

Community
  • 1
  • 1
jcomeau_ictx
  • 37,688
  • 6
  • 92
  • 107