Skip to content

Desktop Compiler: Installation Instructions

Abhishek Thakur edited this page Sep 21, 2020 · 9 revisions

Raspberry Pi Toolchains Logo

Raspberry Pi GCC Desktop 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 exclusively for GCC version 10.2.0 and x86 compiler only but instructions are similar for x86_64 comiler.

  • 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

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:

Toolchains Binaries Status GCC versions
Raspberry Pi GCC x86 Toolchains (Buster) Beta/Experimental 10.2.0 (x86)
Raspberry Pi GCC x86_64 Toolchains (Buster) Beta/Experimental 10.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 an immediate application OR can be installed permanently for on a daily basis usage.

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

  • Extraction: Extract using tar terminal command as follows:

    tar xf <filename e.g desktop-gcc-10.2.0-pi_x86.tar.gz>
  • Linking:

    • Setup paths as follows:
    PATH=/<extracted folder-name e.g pi-gcc-10.2.0-x86>/bin:$PATH
    LD_LIBRARY_PATH=/<extracted folder-name e.g pi-gcc-10.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-10.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-10.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-10.2.0-x86>/bin:$PATH' >> .profile  
       echo 'export LD_LIBRARY_PATH=/opt/<extracted folder-name e.g pi-gcc-10.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-10.2.0-x86>/bin:$PATH' >> .bashrc
       echo 'export LD_LIBRARY_PATH=/opt/<extracted folder-name e.g pi-gcc-10.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-10.2.0"
    export CC="gcc-10.2.0"
    export CXX="g++-10.2.0"
    export CPP="cpp-10.2.0"
    export FC="gfortran-10.2.0"
    export RANLIB="gcc-ranlib-10.2.0"
    export LD="$CXX"
  • Further, To enable Link-time-optimization (LTO):

    GCCPATH="/<extracted folder-name e.g pi-gcc-10.2.0-x86>/libexec/gcc/arm-linux-gnueabihf/10.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