Install gcc-arm-linux-gnueabi and binutils-arm-linux-gnueabi packages, and then just use arm-linux-gnueabi-gcc instead of gcc for compilation.

You need to be careful on what flavour of linux and binutils you have on your target system. The newest stuff is hardfloat, in this case you would do:

sudo apt-get install gcc-arm-linux-gnueabihf

This brings in the complete cross-compile environment, including binutils.

For using this GCC in the build process write:

CC=arm-linux-gnueabihf-gcc make
Answer from Maratyszcza on askubuntu.com
Top answer
1 of 4
74

Install gcc-arm-linux-gnueabi and binutils-arm-linux-gnueabi packages, and then just use arm-linux-gnueabi-gcc instead of gcc for compilation.

You need to be careful on what flavour of linux and binutils you have on your target system. The newest stuff is hardfloat, in this case you would do:

sudo apt-get install gcc-arm-linux-gnueabihf

This brings in the complete cross-compile environment, including binutils.

For using this GCC in the build process write:

CC=arm-linux-gnueabihf-gcc make
2 of 4
23

64-bit ARM

For 64-bit ARM, the toolchain prefix is aarch64 and usage is:

sudo apt install gcc-aarch64-linux-gnu
aarch64-linux-gnu-gcc -o main.out main.c

You can try it out on this C hello world with QEMU:

main.c

#include <stdio.h>

int main(void) {
    puts("hello");
}

and then:

sudo apt install qemu-user
qemu-aarch64 main.out

will output:

hello

Then a few fun things you can do to quickly see that ARM is actually running under the hood:

  • GDB step debug it: https://stackoverflow.com/questions/20590155/how-to-single-step-arm-assembly-in-gdb-on-qemu/51310791#51310791
  • log the executed ARM instructions with: qemu-aarch64 -d in_asm,out_asm main.out https://stackoverflow.com/questions/13005303/how-does-native-android-code-written-for-arm-run-on-x86/44505097#44505097

Tested in Ubuntu 19.10.

For reliability in serious applications, the disk image provider must also provide a compatible cross compiler

Although you can install a cross compiler with apt conveniently, I must warn you that this is not necessarily reliable unless explicitly supported by the image provider.

If you pick the cross compiler wrongly, the following may happen:

  • the dynamic linker is at the wrong path: https://stackoverflow.com/questions/31929092/trying-to-run-a-cross-compiled-executable-on-target-device-fails-with-no-such-f/49993116#49993116
  • binary incompatibility with the glibc and any other libraries you link against: https://stackoverflow.com/questions/11107263/how-compatible-are-different-versions-of-glibc

Raspberry PI cross compilation

For RPI in particular, the provided cross compilers are available at: https://github.com/raspberrypi/tools and can be used as explained at: https://raspberrypi.stackexchange.com/questions/64273/installing-raspberry-pi-cross-compiler/83215#83215

git clone https://github.com/raspberrypi/tools
export PATH="$(pwd)/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian-x64/bin:${PATH}"
printf '#include <stdio.h>\nint main() { puts("hello world"); }\n' > hello_world.c
printf '#include <iostream>\nint main() { std::cout << "hello world" << std::endl; }\n' > hello_world.cpp
arm-linux-gnueabihf-gcc -std=c99 -o hello_world_c hello_world.c
arm-linux-gnueabihf-g++ -std=c++11 -o hello_world_cpp hello_world.cpp

Ubuntu cross compilation

If you want to cross compile for Ubuntu arm64, I have never been able to find a clear reference on which cross compilers support which distro version: What are the officially supported cross compilers for Ubuntu server alternative architectures like ARM?

Buildroot

My favorite alternative is to build your own image with Buildroot: https://stackoverflow.com/questions/47557262/how-to-download-the-torvalds-linux-kernel-master-recompile-it-and-boot-it-wi/49349237#49349237

This builds everything from source, including the toolchain and the image, and ensures that everything is compatible.

🌐
Arm Learning
learn.arm.com › install-guides › gcc › cross
Cross-compiler | Arm Learning Paths
Use the apt command to install the cross-compilers for 32-bit and 64-bit Arm Linux targets. sudo apt update sudo apt install gcc-arm-linux-gnueabihf -y sudo apt install gcc-aarch64-linux-gnu -y · The GCC version installed is tied to your Ubuntu release. For example, Ubuntu 24.04 LTS provides GCC 13 and Ubuntu 25.10 provides GCC 15.
Discussions

How to install cross-compiler on Ubuntu 18.04? - Unix & Linux Stack Exchange
I guess I just find it surprising ... arm-linux-gnueabi”) when apt-file search only searches package contents (which also incidentally finds package names, thanks to /usr/share/doc//copyright). ... As steeldriver suggests, you already have installed the cross-compiler; the problem ... More on unix.stackexchange.com
🌐 unix.stackexchange.com
April 2, 2019
c - How to cross compile for ARM on Ubuntu conditionally? - Stack Overflow
I have written the following make file all: writer.o writer.o: gcc -Wall writer.c -o writer clean: rm *.o How do I add a functionality to this make file such that I am able to generate an More on stackoverflow.com
🌐 stackoverflow.com
linux - How to install cross compiler (on ubuntu 12.04 LTS) for microprocessor SA1100? - Stack Overflow
Can someone please tell me how to install the cross compiler (programming language C) for the SA1100 microprocessor? I have ubuntu 12.04 LTS. I´m a complete noob to Linux, I just installed Ubuntu yesterday. I need a special variant of the GCC compiler that is named "arm-unknown-linux-gnu-gcc" ... More on stackoverflow.com
🌐 stackoverflow.com
gcc - Cross-Compiling for an embedded ARM-based Linux system - Stack Overflow
I try to compile some C code for an embedded (custom) ARM-based Linux system. I set up an Ubuntu VM with a cross-compiler named arm-linux-gnueabi-gcc-4.4 because it looked like what I needed. Now w... More on stackoverflow.com
🌐 stackoverflow.com
🌐
Jensd's I/O buffer
jensd.be › 1126 › linux › cross-compiling-for-arm-or-aarch64-on-debian-or-ubuntu
Cross compiling for arm or aarch64 on Debian or Ubuntu | Jensd's I/O buffer
January 26, 2021 - For example, to use your standard PC, most likely x86, to build something that is usable on another machine or device that’s on another architecture, like ARM. In this post, I’ll explain how to do cross compiling for 32bit ARM (arm) or 64bit ARM (aarch64) using Debian 10 or Ubuntu 20.04 LTS.
🌐
Ubuntu Wiki
wiki.ubuntu.com › KernelTeam › ARMKernelCrossCompile
KernelTeam/ARMKernelCrossCompile - Ubuntu Wiki
sudo apt-get install fakeroot build-essential kexec-tools kernel-wedge gcc-arm-linux-gnueabihf sudo apt-get install gcc-arm-linux-gnueabihf libncurses5 libncurses5-dev libelf-dev sudo apt-get install asciidoc binutils-dev sudo apt-get build-dep linux · Then download the code, switch to the omap4 branch and kick a build: git clone git://kernel.ubuntu.com/ubuntu/ubuntu-precise.git cd ubuntu-precise git checkout -b ti-omap4 origin/ti-omap4 export $(dpkg-architecture -aarmhf); export CROSS_COMPILE=arm-linux-gnueabihf- fakeroot debian/rules clean fakeroot debian/rules binary-omap4
🌐
Jensd's I/O buffer
jensd.be › 800 › linux › cross-compiling-for-arm-with-ubuntu-16-04-lts
Cross compiling for ARM with Ubuntu 16.04 LTS | Jensd's I/O buffer
The goal of cross compiling is to compile for one architecture on machine running another one. In this post, I’ll try to explain the steps required to be able to compile software that is executable on ARM-based hardware using a “normal” x64-based PC or virtual machine.
🌐
Stack Overflow
stackoverflow.com › questions › 70824666 › how-to-cross-compile-for-arm-on-ubuntu-conditionally
c - How to cross compile for ARM on Ubuntu conditionally? - Stack Overflow
This makefile is wrong. You've got a object as a target / rule, and you're compiling a binary instead of the object. It works in this case, but it's just wrong generally. ... Set the CROSS_COMPILE variable itself to the compiler prefix.
Find elsewhere
🌐
Jasonblog
jasonblog.github.io › note › arm_emulation › using_ubuntu_arm_cross-compiler_for_bare_metal_programming.html
Using Ubuntu ARM cross-compiler for bare metal programming | Jason note
This compiler is a welcome addition (thanks to the maintainer Marcin Juszkiewicz and to the Linaro team) to the default repositories, and it is in line both with the Ubuntu roadmap to appear also on ARM-based devices and with the ARM roadmap to appear also on server solutions. The main purpose of the package is to allow cross-compiling of Linux programs for Ubuntu ARM distributions, but it can be used also for bare metal programming.
🌐
Ubuntu
packages.ubuntu.com › search
Ubuntu – Package Search Results -- gcc-arm
October 1, 2020 - noble (24.04LTS) (devel): GCC cross compiler for ARM Cortex-R/M processors [universe] 15:13.2.rel1-2: amd64 arm64 armhf ppc64el riscv64 s390x
🌐
Acmesystems
acmesystems.it › arm9_toolchain
Install the ARM cross compiler toolchain on your Linux PC
Install the GCC, G++ cross compilers and support programs by typing: sudo apt update sudo apt install libc6-armel-cross libc6-dev-armel-cross binutils-arm-linux-gnueabi libncurses5-dev build-essential bison flex libssl-dev bc
🌐
GitHub
gist.github.com › rikka0w0 › 5c21900f6a6af74d745cd76fe33c7b7c
Setup a ubuntu cross compiling environment for arm · GitHub
Comment out all in: /etc/apt/apt.conf.d/docker-clean and then pt update https://askubuntu.com/questions/735189/enabling-auto-completion-for-apt-get-install-in-docker-ubuntu-14-04/1026978#1026978 https://askubuntu.com/questions/86375/apt-get-autocomplete-package-name-is-broken \ apt install -y sudo nano wget curl git python \ gcc-arm-linux-gnueabi gcc-arm-linux-gnueabihf\ make gcc binutils patch build-essential libssl-dev bc\ flex bison gawk libncurses5-dev gettext autoconf texinfo
Top answer
1 of 2
22

As I told in comments, try

apt-get install gcc-arm-linux-gnueabi 

or

apt-get install gcc-4.7-arm-linux-gnueabi

I also strongly recommend being able to compile an ordinary C program for your Linux system (i.e. learn the basics of gcc, make ... commands and how to use some editor like emacs or gedit ...) and the cross compiler you want also depends upon the system running on your SA1100 hardware board. Don't forget to pass -Wall to any GCC compilation. You probably want to be able to debug your program (pass -g to GCC at compilation, and use the gdb debugger). When your program is running well, compile it with -O2 to ask GCC to optimize its machine code.

Learn to use GNU make -e.g. to write Makefile-s- by reading its documentation and use the arm-linux-gnueabi-gcc as the cross-compiler program. (You might want to use remake to debug your Makefile-s when make does not help enough)

You can get the list of files installed with a package with e.g. dpkg -L gcc-arm-linux-gnueabi

A cross compiled program executable for ARM very probably needs a Linux kernel with some libc (or link it statically) at least on the ARM motherboard, and you need some way to transmit the binary program from the Linux desktop to the ARM hardware.

2 of 2
5

Add the ppa: https://launchpad.net/gcc-arm-embedded The source codes for both are same. Currently supports Ubuntu 10.04/12.04/13.04/13.10/14.04 32 and 64 bit.

Detailed explanations to Launchpad PPA can be found at https://help.launchpad.net/Packaging/. That website explains how a PPA is set up and how to add existing PPA and install software from it.

Here are quick steps to install toolchain from this PPA on Ubuntu before 14.04. Open a terminal and type :

  1. sudo add-apt-repository ppa:terry.guo/gcc-arm-embedded
  2. sudo apt-get update
  3. sudo apt-get install gcc-arm-none-eabi

To remove installed toolchain, just do :

sudo apt-get remove gcc-arm-none-eabi

To update the toolchain, just repeat step 2 and 3.

🌐
LinuxVox
linuxvox.com › blog › building-arm-gnu-cross-compiler
How to Build an ARM GNU Cross Compiler Toolchain on Ubuntu: A Modern Guide for Linux Developers — linuxvox.com
ARCH=arm: Target ARM architecture (use ARCH=arm64 for ARM64). INSTALL_HDR_PATH: Install headers to the toolchain’s include directory. Now build GLIBC using the bootstrap GCC and Linux headers. ... mkdir -p build/glibc cd build/glibc ../../src/glibc-2.38/configure \ --target=$TARGET \ --prefix=$PREFIX/$TARGET \ # Install to toolchain's target directory --host=$TARGET \ # Cross-compiling GLIBC itself --with-headers=$PREFIX/$TARGET/include \ # Linux headers path --enable-multilib \ --disable-werror
🌐
Qt Forum
forum.qt.io › home › qt development › installation and deployment › using cross-compilation for arm64 in the ubuntu 24.04 x86 environment
Using cross-compilation for ARM64 in the Ubuntu 24.04 x86 environment | Qt Forum
March 10, 2025 - sudo apt-get install gcc-aarch64-linux-gnu g++-aarch64-linux-gnu $ which aarch64-linux-gnu-gcc /usr/bin/aarch64-linux-gnu-gcc $ aarch64-linux-gnu-gcc --version aarch64-linux-gnu-gcc (Ubuntu 13.3.0-6ubuntu2~24.04) 13.3.0 Copyright (C) 2023 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. After verifying the cross-compilation tool, enter the Qt/6.8.2/ directory, create a folder, and start compiling. cd ./Qt/6.8.2/ mkdir arm64 mkdir build && cd build ../Src/configure -prefix /home/ptc/Qt/6.8.2/arm64 -platform linux-g++ -device linux-aarch64-gnu-g++ -device-option CROSS_COMPILE=aarch64-linux-gnu- -no-opengl -make libs
🌐
Ubuntu Wiki
wiki.ubuntu.com › Oxide › ArmCrossCompiling
Oxide/ArmCrossCompiling - Ubuntu Wiki
Oxide supports cross compiling ARM builds with Ubuntu's multiarch toolchain.
🌐
96Boards
96boards.org › documentation › guides › crosscompile › commandline.html
Cross Compile files on x86 Linux host for 96Boards ARM systems - 96Boards
This three part set of instructions will walk you through basic commandline cross compilation on a Linux x86 system for ARM 96Boards devices. Linux host system is used as the cross compiling station · Examples were tested on fully updated Ubuntu 15.04 and 16.04 releases
🌐
GitHub
github.com › gabime › spdlog › issues › 2425
How to cross-compile on Linux using the ARM compiler? · Issue #2425 · gabime/spdlog
July 8, 2022 - set(CMAKE_C_COMPILER "/opt/Sourcery_CodeBench_Lite_for_Xilinx_GNU_Linux/bin/arm-xilinx-linux-gnueabi-gcc") set(CMAKE_CXX_COMPILER "/opt/Sourcery_CodeBench_Lite_for_Xilinx_GNU_Linux/bin/arm-xilinx-linux-gnueabi-g++") ... -- The CXX compiler identification is GNU 9.3.0 -- Check for working CXX compiler: /usr/bin/c++ -- Check for working CXX compiler: /usr/bin/c++ -- works -- Detecting CXX compiler ABI info -- Detecting CXX compiler ABI info - done -- Detecting CXX compile features -- Detecting CXX compile features - done -- Build spdlog: 2.0.0 -- Looking for C++ include pthread.h -- Looking for
Author   gabime