Home

last update: 2024-11-02 at 02:00:12 CET

Cross Compilation

For Raspberry PI 4b

Target OS
$ lsb_release -a
Distributor ID: Debian
Description:    Debian GNU/Linux 12 (bookworm)
Release:        12
Codename:       bookworm
Target Architecture
$ uname -a
Linux raspberrypi 6.1.0-rpi7-rpi-v8 #1 SMP PREEMPT Debian 1:6.1.63-1+rpt1 (2023-11-24) aarch64 GNU/Linux
Install aarch64 Toolchain
$ sudo apt install g++ make g++-aarch64-linux-gnu binutils-aarch64-linux-gnu
vim /tmp/test.cpp
Compile A Simple Test Program
aarch64-linux-gnu-g++ /tmp/test.cpp -o /tmp/test
$ file /tmp/test
/tmp/test: ELF 64-bit LSB pie executable, ARM aarch64, version 1 (SYSV), dynamically linked, interpreter /lib/ld-linux-aarch64.so.1, BuildID[sha1]=922ad8c0b53cd3731b98116feb275e61d0f5d6bf, for GNU/Linux 3.7.0, not stripped