Raspberry Pi Hello Cross Compile

A special Raspberry Pi Hello World project to demo cross compiling via Docker


Note: These instructions were written for a Mac. Yes a Mac. You perform these steps on a Mac - not a Pi.

To cross compile you need to use a special Docker image that I created. To do that you will need to install Docker. Once you have done that, do the following:

mkdir ~/raspberry

cd ~/raspberry

git clone --depth=1 hello

docker run -it -v ~/raspberry/hello:/build mitchallen/pi-cross-compile

The first time this runs it will take a while to download the docker image. But once it is cached, subsequent runs should go quickly.

When the run is finished you should find a binary that will only run on a Raspberry Pi located at: ~/raspberry/hello/bin/hello. It's up to you to figure out how to load it onto your Pi.


This project contains a Makefile that expects to find the Raspberry Pi Cross Compiler tools located at /pitools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian-x64/bin/arm-linux-gnueabihf-gcc. The tools themselves can be found at

To put the tools in the correct location (pitools), the docker image was created using this command:

git clone --progress --verbose --depth=1 pitools

To cross compile using gcc the Makefile refers to the gcc compiler with this line:


For other tools in that folder, browse here.

To get a better sense of how things work, view the Makefile in the root of this repo.



In lieu of a formal style guide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code.

Version History

Version 0.1.4 release notes

  • Restructured Makefile and project structure

Version 0.1.3 release notes

  • Updated hello message with newlines for easier reading in terminal window

Version 0.1.2 release notes

  • Added cd command to sample usage

Version 0.1.1 release notes

  • Added a placeholder so bin folder will be created when cloned.

Version 0.1.0 release notes

  • Initial release