Cross compilation for rPI and derivatives (e.g. norns)

I thought this might be interesting to some here…
basically its a way to quickly and easily (no tech knowledge required) setup a cross compile environment on your mac or linux box.

this started out for Bela… where I got a little frustrated at the compile time of some of my projects (which are pretty large ) , and wanted to quickly setup a cross-compilation environment on my various macs and linux boxes… and frankly, having done it before I kept ‘putting it off’ as its alway been a bit ‘fiddly’ to setup.

so rather than just install/setup on one box, I thought id try to script it… so its repeatable.

also, I wanted to take the opportunity to do this with modern tools, so this is all based on llvm, clang-10 and supporting cmake.

once working on bela, it was quick n’ easy to adapt it so I can use it with Organelle, Norns, Terminal Tedium, Nebulae , Patchbox… and gives me a consistent approach to developing for them all - which is nice :slight_smile: … this has become xcRpi.

anyway, ‘nothing new’ here, really just a few scripts (with various ‘hook’) based on the outstanding development work others have been doing on clang, llvm, cmake, apt, homebrew etc.

but I thought it might be interesting to some, if like me, they have found that cross compiling can be a bit of a pain to setup… so I put in some effort to ensure it’s ‘reasonably’ well documented, so easy to use.

related bela project : ( GitHub - TheTechnobear/xcBela: cross compiling for bela )
basically the same as xcRpi, just with some bela specifics added.

of course, open source, so if anyone has any idea for improvements etc, Id happily accept pull requests.
(note: my aim is rather for simplicity, than it being any kind of ‘ultimate’ setup… )



As a very recent RPi developer (if I can call myself that), I’d love a few more details about what this is because I’m not super well-educated on the jargon. Is it like a virtual RPi machine, so I can develop on my PC/Mac and then move it over to an SD card for an RPi?

Glancing at the code, the main thing it seem to do is set up what is known as a cross-compiler. This allows you to compile code on your PC that targets the Pi architecture, which can then be copied over the the Pi using scp (ssh copy).

If you’re on a Mac with dev tools set up, included with it will be a compiler for C/C++. C/C++ code goes in, and out pops a binary. The Mac compiler will produce binaries that run only on your mac. If you try to copy this binary on your mac to a Pi, it will not run.

Enter the cross compiler. This is something that you can install on your PC. Like before, C/C++ goes in, binaries come out. Except this time, it is a binary designed to run on a Pi, even though it was produced on a PC. It will not be able to run on your PC. You’d have to copy this to a Pi to make it run.

Why do this at all? Why not just build stuff right there on the Pi? Well, you can, and we do. But, for larger codebases, compiling can take a long time. PC/Mac computers can do the same thing in a fraction of the time using the tools you normally use, so it’s a much more comfortable way to develop for these systems.

Hope that helps.


absolutely interesting… thank you! :slightly_smiling_face: