Skip to content

Desktop Compiler: Installation Instructions

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

Raspberry Pi Toolchains Logo

Raspberry Pi GCC Desktop ARM Toolchains Setup Guide

These toolchains can be used directly on x86 & x86_64 Raspberry Pi Desktop Buster OS for compiling programs for it.

 

Important

  • These instructions are Linux-machines specific only

 

Table of content

 

 

A. Prerequisites

  • Update your environment:

    sudo apt update && sudo apt dist-upgrade
  • Install Important Packages(including default gcc):

    sudo apt-get install build-essential gawk gcc g++ gfortran git texinfo bison  wget bzip2 libncurses-dev libssl-dev openssl zlib1g-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
Exclusive/Experimental Toolchains x86/x86_64 Pi Desktop x86/x86_64 Pi Desktop Beta/Experimental 14.2.0 (x86), 14.2.0 (x86_64)

 

 

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 desktop-gcc-14.2.0-pi_x86.tar.gz>
  • Linking:

    • Setup paths as follows:
    PATH=/<extracted folder-name e.g pi-gcc-14.2.0-x86>/bin:$PATH
    LD_LIBRARY_PATH=/<extracted folder-name e.g pi-gcc-14.2.0-x86>/lib:$LD_LIBRARY_PATH

 

C2. Permanent Installation:

  • Extraction: Extract using tar terminal command as follows:

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

    sudo mv <extracted folder-name e.g pi-gcc-14.2.0-x86> /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 pi-gcc-14.2.0-x86>/bin:$PATH' >> .profile  
       echo 'export LD_LIBRARY_PATH=/opt/<extracted folder-name e.g pi-gcc-14.2.0-x86>/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 pi-gcc-14.2.0-x86>/bin:$PATH' >> .bashrc
       echo 'export LD_LIBRARY_PATH=/opt/<extracted folder-name e.g pi-gcc-14.2.0-x86>/lib:$LD_LIBRARY_PATH' >> .bashrc
       source .bashrc

 

 

D. Advanced Information

  • Extra Step to use these binaries(temporarily) as your default native GCC Compiler(instead of default GCC 8.3.0) at the time of compilation:
    export AR="gcc-ar-14.2.0"
    export CC="gcc-14.2.0"
    export CXX="g++-14.2.0"
    export CPP="cpp-14.2.0"
    export FC="gfortran-14.2.0"
    export RANLIB="gcc-ranlib-14.2.0"
    export LD="$CXX"
  • Further, To enable Link-time-optimization (LTO):
    GCCPATH="/<extracted folder-name e.g pi-gcc-14.2.0-x86>/libexec/gcc/arm-linux-gnueabihf/14.2.0"
    export ARFLAGS="--plugin $GCCPATH/liblto_plugin.so"
    export RANLIBFLAGS="--plugin $GCCPATH/liblto_plugin.so"

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.

Clone this wiki locally