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?

  • 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, 2015 at 3:09

2 Answers 2


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.

  • Where did you get the sysroot?
    – Bogi
    Apr 20, 2021 at 14:40

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

  • The OP asked for 'Clang and LLVM'
    – drudru
    Aug 22, 2017 at 21:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.