raspberry:cross-platform-compile:cross-compile-overview
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| raspberry:cross-platform-compile:cross-compile-overview [2026/09/04 06:13] – [Cross Platform Development for Raspberry] oscar | raspberry:cross-platform-compile:cross-compile-overview [2026/12/01 04:06] (current) – removed - external edit (Unknown date) 127.0.0.1 | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| - | ====== Cross Platform Development for Raspberry ====== | ||
| - | ---- | ||
| - | Cross-development means developing and compiling programs on another platform then it intended to run upon. It is a common approach for Pi, since it’s also how Raspian is built. For quite some time I did compile Pi applications on the Pi itself. Which works quite well, but has one large drawback: performance. Being able to compile these programs on my 8 core 16GB desktop, improved compilation time enorm. And it is quite simple. | ||
| - | There are multiple approaches to setup a cross-compile environment. The most essential aspect is the following: | ||
| - | |||
| - | - Exact **identical Linux/ | ||
| - | - **Different Linux/ | ||
| - | |||
| - | - [[raspberry: | ||
| - | - [[raspberry: | ||
| - | |||
| - | [[raspberry: | ||
| - | |||
| - | ===== Compatibility rule ===== | ||
| - | Build against the oldest operating-system release and CPU that the resulting | ||
| - | binary must support. Do not link a Bookworm target against Trixie ARM libraries. Doing so can create | ||
| - | dependencies on newer glibc or library symbols that are unavailable on the | ||
| - | Bookworm target. For example: | ||
| - | < | ||
| - | Incorrect: | ||
| - | Trixie compiler + Trixie armhf libraries -> Bookworm target | ||
| - | |||
| - | Correct: | ||
| - | Trixie compiler + Bookworm armhf sysroot -> Bookworm target | ||
| - | </ | ||
| - | |||
| - | ===== The problem with different host and target ARM libraries ===== | ||
| - | The important guideline is that **the target system' | ||
| - | < | ||
| - | HOST | ||
| - | Debian Trixie x86-64 | ||
| - | │ | ||
| - | │ cross compiler | ||
| - | ▼ | ||
| - | | ||
| - | │ | ||
| - | | ||
| - | WRONG approach | ||
| - | | ||
| - | | ||
| - | Trixie armhf libs Bookworm Raspbian armhf libs | ||
| - | | ||
| - | | ||
| - | ARM executable | ||
| - | | ||
| - | | ||
| - | ▼ | ||
| - | Raspbian Bookworm | ||
| - | </ | ||
| - | Suppose your **x86 host is Debian Trixie**, and you install **libc6: | ||
| - | Your compiler might then build against something like **glibc 2.41** while your Raspberry Pi's Raspbian Bookworm has **glibc 2.36**. Your executable may therefore acquire a dependency on a newer GLIBC symbol. | ||
| - | For example, conceptually: | ||
| - | < | ||
| - | program | ||
| - | └── was linked against and requires GLIBC_2.41 | ||
| - | │ | ||
| - | ▼ | ||
| - | | ||
| - | │ | ||
| - | ✗ | ||
| - | | ||
| - | " | ||
| - | </ | ||
| - | This is one of the most common reasons why **building on a newer distribution for an older target** causes trouble. It isn't only the **libraries** that matter. The headers matter too. Suppose you compile against Trixie' | ||
| - | * API definitions | ||
| - | * feature macros | ||
| - | * structure definitions | ||
| - | * constants | ||
| - | * kernel interfaces | ||
| - | * glibc interfaces | ||
| - | * library-specific APIs | ||
| - | So the ideal relationship is: | ||
| - | |||
| - | That's why a **target-specific sysroot** is the clean solution. | ||
| - | |||
| - | ===== But the reverse is usually fine ===== | ||
| - | If you deliberately want to require a newer target system, that's perfectly legitimate. For example: | ||
| - | < | ||
| - | Build against Trixie armhf | ||
| - | ↓ | ||
| - | Deploy only to Trixie armhf | ||
| - | ↓ | ||
| - | No problem. | ||
| - | </ | ||
| - | The rule is simple: **Don' | ||
| - | |||
| - | ====== Raspberry Pi OS vs Debian armhf ====== | ||
| - | One important distinction: | ||
| - | target. Use Debian repositories only when the target is Debian armhf. | ||
| - | |||
| - | If your target is **Raspberry Pi OS 32-bit**, don't blindly assume that Debian Bookworm' | ||
| - | |||
| - | > Raspberry Pi OS armhf can be subtly incompatible with Debian armhf. | ||
| - | |||
| - | In particular, Raspberry Pi OS/Raspbian has historically had differences in its ARM ABI/build configuration. Debian recommends using a target-specific chroot when cross-compiling packages for Raspberry Pi OS armhf. ([Debian Wiki][2]) | ||
| - | |||
| - | |||
| - | ====== Links ====== | ||
| - | * https:// | ||
| - | * https:// | ||
| - | * https:// | ||
| - | * https:// | ||
| - | * https:// | ||
| - | * https:// | ||
| - | * https:// | ||
raspberry/cross-platform-compile/cross-compile-overview.1788502427.txt.gz · Last modified: by oscar
