Skip to content

Cross Compiler: Installation Instructions

Abhishek Thakur edited this page Dec 14, 2021 · 53 revisions

Raspberry Pi Toolchains Logo

Raspberry Pi GCC Cross-Compiler ARM Toolchains Setup Guide

These ARM toolchains can be used on any Linux Distributions (32-bit/64-bit) for cross-compiling programs for Raspberry Pi 32-bit OSes.

💡 Note: Our Cross-Compiler toolchains also works out-of-the-box on any Linux distro via WSL2 on Windows 10 Machines. 💯
  • Stretch: Generates programs for Raspbian Stretch OS (Debian Version 9) and equivalent OS only.

    • GCC core libraries version:
      • Glibc version: 2.24
      • Binutils version: 2.28
      • GDB version: 9.2
  • Buster: Generates programs for Raspbian Buster OS (Debian Version 10) and equivalent OS only.

    • GCC core libraries version:
      • Glibc version: 2.28
      • Binutils version: 2.31
      • GDB version: 9.2
  • Bullseye: Generates programs for Raspbian 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.1
      • GDB version: 10.2

 


Important ⚠️

  • These instructions are exclusively for GCC version 9.2.0 but will work with any 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

Compressed pre-compiled GCC Toolchain binaries can be easily be downloaded from the project's SourceForge Repository by clicking links given in the following table:

References:

  • Host OS: on which the toolchain is executed/used.
  • Target OS: for which the toolchain generates code.
Toolchains Host OS Target OS Current Status Precompiled GCC versions available
Raspberry Pi GCC Cross-Compiler Toolchains (Stretch) any x64/x86 Linux machine Stretch 32-bit OS (Debian Version 9) only Stable/Production 6.3.0, 9.4.0, 10.3.0
Raspberry Pi GCC Cross-Compiler Toolchains (Buster) any x64/x86 Linux machine Buster 32-bit OS (Debian Version 10) only Stable/Production 8.3.0, 9.4.0, 10.3.0
Raspberry Pi GCC Cross-Compiler Toolchains (Bullseye) any x64/x86 Linux machine Bullseye 32-bit OS (Debian Version 11) only Stable/Production 10.2.0, 10.3.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-9.2.0-pi_2-3.tar.gz>
  • Linking:

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

 

C2. Permanent Installation:

  • Extraction: Extract using tar terminal command as follows:

    tar xf <filename e.g cross-gcc-9.2.0-pi_2-3.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-9.2.0-1> /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-9.2.0-1>/bin:$PATH' >> .profile  
       echo 'export LD_LIBRARY_PATH=/opt/<extracted folder-name e.g cross-pi-gcc-9.2.0-1>/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-9.2.0-1>/bin:$PATH' >> .bashrc
       echo 'export LD_LIBRARY_PATH=/opt/<extracted folder-name e.g cross-pi-gcc-9.2.0-1>/lib:$LD_LIBRARY_PATH' >> .bashrc
       source .bashrc

 

 

D. Advanced Information