Home avatar

A collection of dev guides, tutorials and thoughts on various tech stacks, tools and programming languages.

Cross compile for Raspberry Pi with Docker

The Raspberry Pi is a pretty useful tool for quickly prototyping some IoT product, simulating an embedded environment, running a small Kubernetes cluster, etc; there are probably lots of reasons why you’d want to use one (or maybe not?).

As for developing software that can run on it, if you’re writing it in C or C++, there’s many ways to go about it:

  1. Sync the code changes you make on the Pi and build it natively on it (via rsync, scp, SSHFS, git, etc)
  2. Use crosstool-ng to setup a toolchain and use it to cross-compile your software; then copy the resulting binaries onto the Pi
  3. Use a precompiled toolchain to cross-compile the software; then copy the binaries onto the Pi
  4. Develop directly on the Pi through an SSH session
  5. Use a containerized OS such as Balena

And you can probably find many other creative ways developers came up with.

How to install cmake?

CMake is a cross-platform tool for building, testing and packaging software.

If you’ve been writing C or C++ (or maybe Fortran) you probably had to, at some point, use cmake to package your software.

If you’re a Linux user, you’d normally just need to run:

sudo apt-get install -y cmake

to install it. But sometimes, the version that you can install from the official repository is not the one you need.

How to install OpenSSL 1.1.1?

OpenSSL is a TLS/SSL and crypto library.

Most Linux distributions come packaged with some older version of OpenSSL, but if you need some of newest features (such as support for TLSv1.3), then you’ll need to manually install it.

These instructions should work for most Debian based distros.

Install the build dependencies:

sudo apt-get -y install build-essential checkinstall git zlib1g-dev

Clone OpenSSL: