Skip to content

Cross Compiler: Installation Instructions

Abhishek Thakur edited this page Jan 2, 2020 · 55 revisions

Cross-Compiler ARM Toolchains Setup Guide

Note::bulb: These instructions are exclusively for GCC Cross Compiler version 9.2.0 but will work with any compiler version available with this project.

 

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:

You can easily visit downloading page and find suitable cross-binaries for your Machine. Click Link given below:

 

C. Extracting and Linking Binary:

👉 Temporary Installation: Use these binaries directly (Recommended)

This repository now provides Free-Standing Cross-Compiler Toolchains that gives a common setup for everyone, the same standardized headers with no hardcoded paths, therefore the same solutions for everyone.

  • 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

 

👉 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. Bonus:

  • Extra flag required while using custom SYSROOT Folder during build:

    While using a seperate custom SYSROOT Folder for your builds (for example in case of QT builds), kindly add -no-gcc-sysroot flag to your configure command to avoid undesired errors and failures.

  • Extra step to use Cross-Compiler Binaries with CMAKE:

    Enable CMAKES's implicit directory feature by injecting the following lines into toolchain file: (Refer Issue:#3)

    unset(CMAKE_C_IMPLICIT_INCLUDE_DIRECTORIES)
    unset(CMAKE_CXX_IMPLICIT_INCLUDE_DIRECTORIES)