9

I would like to cross-compile C-family languages (C, C++, Objective-C, and Objective-C++) to the Raspberry Pi using Clang and LLVM on a build computer of a different architecture. How may I do this?

fouric
  • 1,809
  • 4
  • 18
  • 26

2 Answers2

3

Just completed my article, Cross compilation for Raspberry from Sierra, about exactly this thing. Under Mac OS Sierra though. But for clang it matters a little.

In this article I have shared experience (which costed me some days of suffering). Hope it will be useful. In short, all you have to do is to specify rootfs and target triple:

path/to/clang --target=arm-linux-gnueabihf --sysroot=/some/path/arm-linux-gnueabihf/sysroot my-happy-program.c  -fuse-ld=lld

I added -fuse-ld=lld option, because otherwise clang will try to lookup legacy binutils.

Greenonline
  • 2,969
  • 5
  • 27
  • 38
1

I followed this article and it seems to work fine for trivial programs (console/string/math stuff, not many optimization flags). I used ver 1.19 of crosstool-ng on a x86-64 laptop running ZenWalk 7.0

There also seems to be this post over at SO, which might be helpful (haven't fully read thru it yet).

Bhargav
  • 224
  • 3
  • 7