Skip to content

Cross Compiler: Installation Instructions

Abhishek Thakur edited this page May 16, 2019 · 55 revisions

Raspberry Pi Cross Compiler Toolchain Installation Instruction 📑

A. Prerequisites:

  • Update your environment:

    sudo apt-get update && dist-upgrade
  • Install Important Packages:

    sudo apt 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/Raspberry%20Pi%20GCC%20Cross-Compilers/GCC%208.3.0/Raspberry%20Pi%203A%2B%2C%203B%2B/cross-gcc-8.3.0-pi_3%2B.tar.gz'

C. Extracting and Configuring Binary:

  • Extraction: Extract using tar terminal command as follows:

    tar xf <filename e.g cross-gcc-8.3.0-pi_0-1.tar.gz>
  • Configuring: Move extracted folder to its correct location (i.e. /opt) by using following command:

    ⚠️ DO NOT CHANGE EXTRACTED FOLDER NAME FOR BEST COMPATIBILITY!

    sudo mv <extracted folder-name e.g cross-pi-gcc-8.3.0-1> /opt

D. 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-8.3.0-1>/bin:$PATH' >> .profile  
       echo 'export LD_LIBRARY_PATH=/opt/<extracted folder-name e.g cross-pi-gcc-8.3.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-8.3.0-1>/bin:$PATH' >> .bashrc
    echo 'export LD_LIBRARY_PATH=/opt/<extracted folder-name e.g cross-pi-gcc-8.3.0-1>/lib:$LD_LIBRARY_PATH' >> .bashrc
    source .bashrc

E. 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)
Clone this wiki locally