Ubuntu to Raspberry Pi OS Cross C++ Development
Pieter P
This guide explains how to set up a cross-compilation development
environment for the Raspberry Pi. We'll be using the familiar APT package manager
for installing cross-compilation dependencies, so you can just
apt-get install
any library from the Debian or Raspberry Pi OS
repositories.
We use a modern GCC 11 toolchain for C, C++ and Fortran. Configuration files for easy on-target debugging in Visual Studio Code are provided. A hello world CMake project is included as an example.
Everything was tested on Ubuntu 20.04 LTS on the build machine and Raspberry Pi OS Buster on a Raspberry Pi Zero.
If you're targeting a Raspberry Pi running Ubuntu, also see the Ubuntu to Ubuntu Cross C++ Development guide.
Installation and Setup
Installing Raspberry Pi OS and setting up SSH to prepare for remote development.
Development setup
Installing the necessary tools and setting everything up for cross-compilation.
Building the C++ example project
Cross-compiling a C++ project using CMake and with a dependency on the Boost libraries, as an example of how to build any C++ project with nontrivial dependencies.
Remote debugging
Debugging your C++ program from your computer while it is running on the Raspberry Pi.