Cross-compilation for Raspberry Pi in GCC. Where to start?

I found these instructions How to build a cross compiler for your Raspberry Pi. It is a great walk through using a crosstool-ng tool which simplifies configuring a cross-compiler build A LOT (it has a nice curses-based interface) and it supports GCC 4.7.

Seems to work great!


Here is a step-by-step guide How to build Raspberry Pi cross-compiler in Windows. The reason you are getting Illegal Instruction error is latest Raspbian is hardfp-enabled and requires appropriate patches for gcc and eglibc to support hardfp. Otherwise generated code will use different ABI, i.e. pass function arguments in different registers, so crash at runtime.

Also misconfiguring GCC for ARMv7 (Raspebby Pi is ARMv6) may lead to Illegal Instruction error. Be sure to specify --with-arch=armv6 option when configuring GCC.

The guide linked above is based on GCC 4.6.3 though. But I guess it should work with GCC 4.7 too.


http://github.com/dwelch67/raspberrypi buildgcc directory there is a script for both 4.7 gcc/gnu and 3.0 clang/llvm. gnu one derived from the script at the mpx project at opencores, I cut out gdb and libgcc, glibc, etc took it down to a compiler. if you want that other stuff cut and paste arm for mips.


I couldn't find a 4.7 gcc, only a 4.6. For information, I compiled the Pi's kernel on a fairly old Ubuntu machine (1Ghz, 768MB RAM) following the guidelines on this page: Kernel compilation

The build took about 90 minutes, compared to the 6 hours it is suggested that it would take on the Pi. The kernel runs fine on the Pi. Perhaps you can adapt these guidelines for cross-compiling other projects on your x86 Linux machine.