-
-
Notifications
You must be signed in to change notification settings - Fork 107
Cross Compiler: Installation Instructions
Note::bulb: These instructions are exclusively for GCC Cross Compiler version 9.1.0 but will work with all compiler versions available with this project.
-
Update your environment:
sudo apt-get update && dist-upgrade
-
Install Important Packages:
sudo apt-get install build-essential gawk gcc g++ gfortran git texinfo bison libncurses-dev
- 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-Compiler%20Toolchains/GCC%209.1.0/Raspberry%20Pi%202%2C%203/cross-gcc-9.1.0-pi_2-3.tar.gz'
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_2-3.tar.gz>
-
Linking:
PATH=/<extracted folder-name e.g cross-pi-gcc-9.1.0-1>/bin:$PATH LD_LIBRARY_PATH=/<extracted folder-name e.g cross-pi-gcc-9.1.0-1>/lib:$LD_LIBRARY_PATH
-
Extraction: Extract using
tar
terminal command as follows:tar xf <filename e.g cross-gcc-9.1.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.1.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.1.0-1>/bin:$PATH' >> .profile echo 'export LD_LIBRARY_PATH=/opt/<extracted folder-name e.g cross-pi-gcc-9.1.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.1.0-1>/bin:$PATH' >> .bashrc echo 'export LD_LIBRARY_PATH=/opt/<extracted folder-name e.g cross-pi-gcc-9.1.0-1>/lib:$LD_LIBRARY_PATH' >> .bashrc source .bashrc
-
-
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)
If these binaries helped you big time, please consider supporting it. Thank you.
Also, don't forget to share your views & drop a ⭐
- Native-Compiler ARM Toolchains Guide
- Cross-Compiler ARM Toolchains Guide
- Native-Compiler 64-Bit GCC ARM64 Toolchains Guide
- Cross-Compiler 64-Bit GCC ARM64 Toolchains Guide