While Raspberry Pi SBCs have gotten significantly more powerful over the years, they are still pretty limited compared to a PC when it come to compiling. Building a complicated project on a Pi4 or even a Pi5 can be slow, and it is easy to run out of memory when compiling on the smaller (ie: 1-2GB) versions.
I wanted to provide release binaries for Raspberry Pi for several of my GitHub projects, and didn't want to do a manual build and upload. Fortunately, with a bit of digging, I found and was able to use Pieter Pas' docker-arm-cross-toolchain to build for Raspberry Pi using GitHub actions.
Here is an example snippet for setting up a Pi4/Pi5 build matrix in a Github action:
name: Raspberry Pi Build on: workflow_dispatch: jobs: build-rpi: name: Build Raspberry Pi strategy: matrix: native_arch: [rpi4, rpi5] runs-on: ubuntu-latest container: image: ghcr.io/tttapa/docker-arm-cross-toolchain:aarch64-rpi3-linux-gnu-gcc12 steps: ...do something
Note the "gcc12" at the end of the docker image path. This ensures that your RPi build will work on RPi OS versions going back to Bookworm.
When you get to building, assuming that you are using CMake, you can specify the build tools by using:
-DCMAKE_TOOLCHAIN_FILE=/home/develop/opt/x-tools/aarch64-rpi3-linux-gnu/aarch64-${{ matrix.native_arch }}-linux-gnu.toolchain.cmake
You can see this at work in myneural-amp-modeler-lv2 and NeuralAudio GitHub repositories. Have a look at the "release" GitHub actions.


