I'm trying to build a cross-compilation toolchain for Raspberry Pi using Crosstool-NG. And I have already done this. But when I try to use my toolchain with rootfs from Raspberry Pi using the --sysroot
option (as it said in this answer) I get the following error:
/usr/include/features.h:364:25: fatal error: sys/cdefs.h: No such file or directory
The problem is that this header on Raspberry Pi device is located in /usr/include/arm-linux-gnueabihf
, not in just /usr/include
directory. I can add this directory to the list of include directories using -I
flag, but then I get the following error:
/arm-unknown-linux-gnueabihf/bin/ld: cannot find -lm
The problem is similar: the libm
library is located in /usr/lib/arm-linux-gnueabihf
, not in just /usr/lib/
directory. Of course I can use -L
flag to solve this problem, but anyway I get the following error:
/arm-unknown-linux-gnueabihf/bin/ld: cannot find crt1.o: No such file or directory
The reason is the same: crt1.o
is located in the /usr/lib/arm-linux-gnueabihf
directory. And there is no flags to solve this problem. My compiler is configured to search for crt1.o
in the /usr/lib/
directory. And I had to create symbolic links in the /usr/lib
to crt
files in arm-linux-gnueabihf
subdirectory to workaround this problem.
Thus all libc files are located in a non-standard location. crt1.o
on my Ubuntu is also located in a non-standard location, it's located in /usr/lib/i386-linux-gnu
. It seems many toolchains use this behaviour therefore I guess this is some standard feature of gcc.
So the question: is there any option to compile gcc to make it search for headers, libraries and crt1.o
in some specific location? Ho do I configure my toolchain to place all libc files into arm-linux-gnueabihf
subdirectory? I guess there should be some gcc configure option for doing this. But which one?