Skip to content

64 Bit Cross Compiler: Installation Instructions

Abhishek Thakur edited this page Nov 28, 2019 · 38 revisions

Raspberry Pi 64-Bit ARM64 Cross Compiler Toolchain Installation Instructions 📑


⚠️ Important Note:

  • These 64-Bit Compiler Toolchain Binaries will only compile programs for Raspberry Pi Models/Versions with ARMV8-A CPU Architecture that supports 64-Bit execution state(You can find all supported Raspberry Pi Models here) and with Raspberry Pi 64-Bit OS flavors(such as Pi64 by @bamarni) installed.
  • These instructions are exclusively for GCC 64-Bit Cross Compiler version 9.1.0 but will work with all 64-bit compiler versions 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:

  • Visting download page on Browser: You can easily visit downloading page and find suitable cross-binaries for your Machine. Click Link given below:
  • Through Terminal: You can also download files directly from your terminal with wget as follows:
    wget 'https://sourceforge.net/projects/raspberry-pi-cross-compilers/files/Bonus%20Raspberry%20Pi%20GCC%2064-Bit%20Toolchains/Raspberry%20Pi%20GCC%2064-Bit%20Cross-Compiler%20Toolchains/GCC%209.1.0/cross-gcc-9.1.0-pi_64.tar.gz'

 

C. Extracting and Linking Binary:

1. 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 same solutions for everyone.

  • Extraction: Extract using tar terminal command as follows:

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

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

 

2. Permanent Installation:

  • Extraction: Extract using tar terminal command as follows:

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

 

D. Bonus:

  • 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)