This is a guide on how to set up a C++ cross-compilation toolchain and development environment. It serves as the documentation for the RPi-Cpp-Toolchain repository. In this guide, we'll cross-compile all package such as Python, OpenCV and their dependencies from scratch.

Note: building all dependencies from source might not be ideal for most use cases. It is often easier to use a sysroot specific to the operating system you plan to use on the Raspberry Pi (e.g. Raspberry Pi OS or Ubuntu) and use the system package manager (e.g. APT) to install the dependencies. This is explained on the Ubuntu to Raspberry Pi OS Cross C++ Development page.

If you do want to build packages from source, Yocto and Buildroot are good solutions as well.

Overview

The first page guides you through the installation of the necessary tools and editors.

The second and third page explain how to build a cross-compilation toolchain using crosstool-NG, and how to use it to compile the following libraries:

Next, page four explains how to install these libraries to the Raspberry Pi.

The fifth page presents a small “hello world” example project in C++ that uses CMake and Google Test.

Finally, there's a page on remote on-target debugging using GDB and Visual Studio Code.

If you're in a hurry, or if you are already quite familiar with Linux, compilers, etc. you can skip straight to the “Speedrun” page, it contains all the commands you need to get the entire project running in just a couple of minutes.