# How to Build a GCC Cross-Compiler

DevFeed: [How to Build a GCC Cross-Compiler](<https://devfeed.tech/articles/how-to-build-a-gcc-cross-compiler-20998.md>)

Original publisher: [Read original article](<https://preshing.com/20141119/how-to-build-a-gcc-cross-compiler>)

Author: Jeff Preshing

Published: 2014-11-19T11:30:00Z

Content type: tutorial

Language: en

Sources: [Jeff Preshing](<https://devfeed.tech/sources/jeff-preshing.md>)

Topics: [Compiler](<https://devfeed.tech/topics/compiler.md>), [gcc](<https://devfeed.tech/topics/gcc.md>), [C++](<https://devfeed.tech/topics/c-plus-plus.md>), [Arm](<https://devfeed.tech/topics/arm.md>), [Debian](<https://devfeed.tech/topics/debian.md>), [Linux](<https://devfeed.tech/topics/linux.md>), [make](<https://devfeed.tech/topics/make.md>), [Open Source](<https://devfeed.tech/topics/open-source.md>), [apt](<https://devfeed.tech/topics/apt.md>)

Tags: [apt](<https://devfeed.tech/tags/apt.md>), [arm](<https://devfeed.tech/tags/arm.md>), [build](<https://devfeed.tech/tags/build.md>), [built-from-source](<https://devfeed.tech/tags/built-from-source.md>), [c-plus-plus](<https://devfeed.tech/tags/c-plus-plus.md>), [compiler](<https://devfeed.tech/tags/compiler.md>), [debian](<https://devfeed.tech/tags/debian.md>), [gcc](<https://devfeed.tech/tags/gcc.md>), [how-to](<https://devfeed.tech/tags/how-to.md>), [kernel](<https://devfeed.tech/tags/kernel.md>), [linux](<https://devfeed.tech/tags/linux.md>), [linux-kernel](<https://devfeed.tech/tags/linux-kernel.md>), [make](<https://devfeed.tech/tags/make.md>), [open-source](<https://devfeed.tech/tags/open-source.md>), [source](<https://devfeed.tech/tags/source.md>)

## AI overview

A practical guide to building a GCC cross-compiler on Debian Linux for generating C++ programs targeting the 64-bit AArch64 architecture. It explains the required packages, source downloads, build components, and how the resulting compiler, libraries, assembler, linker, and Linux kernel interfaces fit together.

## Source excerpt

GCC is not just a compiler. It's an open source project that lets you build all kinds of compilers. Some compilers support multithreading; some support shared libraries; some support multilib. It all depends on how you configure the compiler before building it. This guide will demonstrate how to build a cross-compiler, which is a compiler that builds programs for another machine. All you need is a Unix-like environment with a recent version of GCC already installed. In this guide, I'll use Debian Linux to build a full C++ cross-compiler for AArch64, a 64-bit instruction set available in the latest ARM processors. I don't actually own an AArch64 device - I just wanted an AArch64 compiler to verify this bug. Required Packages Starting with a clean Debian system, you must first install a few packages: $ sudo apt-get install g++ make gawk Everything else will be built from source. Create a new directory somewhere, and download the following source packages. (If you're following this guide at a later date, there will be more recent releases of each package available. Check for newer releases by pasting each URL into your browser without the filename. For example: http://ftpmirror.gnu.org/binutils/) $ wget http://ftpmirror.gnu.org/binutils/binutils-2.24.tar.gz $ wget http://ftpmirror.gnu.org/gcc/gcc-4.9.2/gcc-4.9.2.tar.gz $ wget https://www.kernel.org/pub/linux/kernel/v3.x/linux-3.17.2.tar.xz $ wget http://ftpmirror.gnu.org/glibc/glibc-2.20.tar.xz $ wget http://ftpmirror.gnu.org/mpfr/mpfr-3.1.2.tar.xz $ wget http://ftpmirror.gnu.org/gmp/gmp-6.0.0a.tar.xz $ wget http://ftpmirror.gnu.org/mpc/mpc-1.0.2.tar.gz $ wget ftp://gcc.gnu.org/pub/gcc/infrastructure/isl-0.12.2.tar.bz2 $ wget ftp://gcc.gnu.org/pub/gcc/infrastructure/cloog-0.18.1.tar.gz The first four packages - Binutils, GCC, the Linux kernel and Glibc - are the main ones. We could have installed the next three packages in binary form using our system's package manager instead, but that tends to provide older versions.