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
  • If the idea is to build your own software from source code (as opposed to building well-known packages from source code and targeting the ARM processor), then checking out something like this will be useful. – WineSoaked Aug 10 '15 at 03:09

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,740
  • 4
  • 23
  • 36
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