Skip to content

64 Bit Cross Compiler: Installation Instructions

Abhishek Thakur edited this page Sep 7, 2024 · 38 revisions

Raspberry Pi Toolchains Logo

Raspberry Pi 64-Bit OS : GCC Cross-Compiler Toolchains Setup Guide

This project now provides exclusive 64-bit ARM64 (aka AArch64) Raspberry Pi GCC Toolchains. These ARM64 Toolchains can be used on any Linux Distributions (32-bit/64-bit) for cross-compiling programs for any Raspberry Pi 64-Bit OS flavors with 64-bit kernel only (such as Raspberry Pi Buster 64-bit OS).

 

Warning

The Stretch (Debian Version 9) 32-bit/64-bit toolchains are no longer supported!

  • Buster: Generates programs for Raspberry Pi Buster 64-bit OS (a.k.a Debian Version 10) and any equivalent OS only.

    • GCC core libraries version:
      • Glibc version: 2.28
      • Binutils version: 2.31.1
      • GDB version: 15.1
  • Bullseye: Generates programs for Raspberry Pi Bullseye 64-bit OS (a.k.a Debian Version 11) and any equivalent OS only.

    • GCC core libraries version:
      • Glibc version: 2.31
      • Binutils version: 2.35.2
      • GDB version: 15.1
  • Bookworm: Generates programs for Raspberry Pi Bookworm 64-bit OS (a.k.a Debian Version 12) and any equivalent OS only.

    • GCC core libraries version:
      • Glibc version: 2.36
      • Binutils version: 2.40
      • GDB version: 15.1

 

Note

Supported Pi Models: These toolchains can be used with any Raspberry Pi Models/Versions with ARMV8-A CPU Architecture that supports 64-Bit execution state. You can find complete all supported Pi's list here.

Important

  • These instructions are exclusively for GCC version 14.2.0 but will work with any cross-compiler version available with this project.
  • These instructions are Linux-machines specific only.

Note

Our Cross-Compiler toolchains also works out-of-the-box on any Linux distro via WSL2 on Windows 10 Machines. 💯

 

Table of content

 

 

A. Prerequisites

  • Update your environment:

    sudo apt update && sudo apt dist-upgrade
  • Install Important Packages:

    sudo apt-get install build-essential gawk gcc g++ gfortran git texinfo bison libncurses-dev

 

 

B. Download Binary

Our pre-compiled TAR-PIGZ compressed and OS-targeted GCC Toolchain binaries can easily be downloaded from the project's SourceForge Repository or by clicking the links provided in the following table:

Download Raspberry Pi GCC Toolchains

Note

  • Host OS: on which the toolchain is executed/used.
  • Target OS: for which the toolchain generates code.

Warning

The Stretch (Debian Version 9) 32-bit/64-bit toolchains are no longer supported!

Toolchains Host OS Target OS Current Status Precompiled GCC versions available
Raspberry Pi GCC 64-Bit Cross-Compiler Toolchains (Buster) any x64/x86 Linux machine Buster 64-bit OS (Debian Version 10) only Stable/Production 8.3.0, 10.2.0, 12.2.0, 13.3.0, 14.2.0
Raspberry Pi GCC 64-Bit Cross-Compiler Toolchains (Bullseye) any x64/x86 Linux machine Bullseye 64-bit OS (Debian Version 11) only Stable/Production 10.2.0, 12.2.0, 13.3.0, 14.2.0
Raspberry Pi GCC 64-Bit Cross-Compiler Toolchains (Bookworm) any x64/x86 Linux machine Bookworm 64-bit OS (Debian Version 12) only Stable/Production 12.2.0, 13.3.0, 14.2.0

 

 

C. Extracting and Linking Binary

These Raspberry toolchains have the same standardized headers with no hardcoded paths, thereby can be directly used for immediate application OR can be installed permanently for on a daily basis usage:

C1. Temporary Installation: Use these binaries directly (Recommended)

  • Extraction: Extract using tar terminal command as follows:

    tar xf <filename e.g cross-gcc-14.2.0-pi_64.tar.gz>
  • Linking:

    PATH=/<extracted folder-name e.g cross-pi-gcc-14.2.0-64>/bin:$PATH
    LD_LIBRARY_PATH=/<extracted folder-name e.g cross-pi-gcc-14.2.0-64>/lib:$LD_LIBRARY_PATH

 

C2. Permanent Installation:

  • Extraction: Extract using tar terminal command as follows:

    tar xf <filename e.g cross-gcc-14.2.0-pi_64.tar.gz>
  • Configuring: Move extracted folder to any location (for e.g. /opt) by using following command:

    sudo mv <extracted folder-name e.g cross-pi-gcc-14.2.0-64> /opt
  • Linking: Properly link Path/Environment Variables permanently with either of the following given methods:

    • Appending variables to your .profile: (Recommended)

       echo 'export PATH=/opt/<extracted folder-name e.g cross-pi-gcc-14.2.0-64>/bin:$PATH' >> .profile  
       echo 'export LD_LIBRARY_PATH=/opt/<extracted folder-name e.g cross-pi-gcc-14.2.0-64>/lib:$LD_LIBRARY_PATH' >> .profile
       source .profile
    • Appending variables to your .bashrc: ⚠️ Some Linux users reported some trouble with configuring path variables at .profile that doesn't seem to work for them. If you encounter a similar problem, try setting/configure by adding paths to your .bashrc file instead of as follows:

       echo 'export PATH=/opt/<extracted folder-name e.g cross-pi-gcc-14.2.0-64>/bin:$PATH' >> .bashrc
       echo 'export LD_LIBRARY_PATH=/opt/<extracted folder-name e.g cross-pi-gcc-14.2.0-64>/lib:$LD_LIBRARY_PATH' >> .bashrc
       source .bashrc

 

 

D. Advanced Information

Note

LTO also needs g++ to be the linker, and it can be enabled at compile-time by setting -flto=$(nproc) and -fno-fat-lto-objects flags in CFLAGS, CXXFLAGS, and LDFLAGS respectively.