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
🌐
Arm Learning
learn.arm.com › install-guides › gcc › cross
Cross-compiler | Arm Learning Paths
This covers gcc and g++ for compiling C and C++ as a cross-compiler targeting the Arm Linux architecture.
🌐
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 - If build and target platform are the same, but host is different, then we’re talking about cross compilation, which this post is covering. When all three platforms are different, it’s called a “canadian”. This is used to build a cross compiler for another architecture. Just to be clear, in this post, the build and target platform are x86_64 (standard PC) and the host is the ARM platform.
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.

🌐
96Boards
96boards.org › documentation › guides › crosscompile › commandline.html
Cross Compile files on x86 Linux host for 96Boards ARM systems - 96Boards
Instructions can be found here ... a simple application using Linux C and C++ toolchains. Cross compilation will happen on a Linux x86 machine for 96Boards ARM device....
🌐
Medium
ruvi-d.medium.com › a-master-guide-to-linux-cross-compiling-b894bf909386
A master guide to Linux cross compiling | by Ruvinda Dhambarage | Medium
January 18, 2026 - Thus getting into a cross compiling task, you need to understand which build system you are dealing with and then do the necessary configuration updates needed to setup for a cross build. Nothing beats “reading the freaking manual” here, but here is my cheat sheet to get you started: # Make > export CROSS_COMPILE=arm-cortex_a8-linux-gnueabihf- > make > make DESTDIR=$(arm-cortex_a8-linux-gnueabihf-gcc -print-sysroot) install # Autoconfig > export CC=arm-cortex_a8-linux-gnueabihf-gcc \ CXX=arm-cortex_a8-linux-gnueabihf-g++ > ./configure --host=arm-cortex_a8-linux-gnueabihf > make > make DESTDIR=$(arm-cortex_a8-linux-gnueabihf-gcc -print-sysroot) install # CMake > cmake -DCMAKE_C_COMPILER=arm-cortex_a8-linux-gnueabihf-gcc \ -DCMAKE_CXX_COMPILER=arm-cortex_a8-linux-gnueabihf-g++ \ -DCMAKE_INSTALL_PREFIX=$(arm-cortex_a8-linux-gnueabihf-gcc -print-sysroot) ..
Top answer
1 of 6
4

It is a hard but doable task.

It depends on what ARM series you are compiling against. On many systems you find a Cortex-A (armv7-a or higher) or ARM11 (armv6) processor running a "mini Linux distribution", this is the case for many POS (Point of Sale) devices. In such a case your target can be one of the following:

  • arm-linux-gnueabi
  • arm-linux-gnueabihf

Where hf stands for hard-float, meaning that the CPU has a FPU (floating-point unit), all Cortex-A support this, but also depends on the underlying OS. It is also very important to know the version of the glibc on the embedded Linux, because if versions are not the same between compiler and OS, unexpected behavior may occur.

If you are compiling against an ARM processor without MMU (Memory Magament Unit) like the Cortex-R or Cortex-M series, and that by consequence do not support Linux (only microkernels like FreeRTOS) your target would be (also known as bare-metal):

  • arm-none-eabi

ARM now distributes the binaries of GCC:

https://developer.arm.com/tools-and-software/open-source-software/developer-tools/gnu-toolchain/gnu-a/downloads

Previously it was Linaro. Yet they keep GCC 7.x for arm-linu-gnueabi (soft-float) if you need it.

https://releases.linaro.org/components/toolchain/binaries/latest-7/

Linaro also used a build system known as ABE, I have not found much documentation on it, but they used it to configure and build the toolchains distributed by them.

If none of the above works for you, you can still build your own toolchain, for that task I suggest using crosstool-ng: https://crosstool-ng.github.io/

Works best under a Linux OS like Ubuntu (you can still try to use Cygwin to build it on Windows, but it may take more time). Note that you do not need to compile it in the machine you want to run it, meaning that you can compile on Ubuntu the GCC that will run on Windows which will produce programs that run on ARM processor, this is known as Canadian Cross.

2 of 6
2

I recommend getting a cross-compiler binary. On a Linux distribution it is often already packaged.

However, if you insist on building GCC from source (but beware of dependencies), read about Installing GCC and about Configuring GCC. You should build it outside of the source tree, and you want to pass some particular --target= option. I also recommend something like --program-suffix=_my

(I have no idea what --target is relevant for your particular configuration & board; you need to find out)

Notice that a target is not only a CPU, but also an OS....

🌐
FIRMWARE DEVELOPER
firmcodes.com › home › how to cross compile for arm
How to cross compile for ARM
February 10, 2017 - After extracting tar file you would get “opt” directory go to that directory and find bin directory where you can get compiler and all that stuff required for cross compilation. Set PATH variable to bin of tool-chain, so that your OS load binaries from that directory too. Use following line to do that · export PATH=<Absolute_path_from_root_directory_to_bin_directory_of_your_downloaded_tool-chain)>:$PATH · To check whether your OS use binaries from your tool-chain folder, write arm and press tab it will show you different binaries of tool-chain.
Find elsewhere
🌐
NASA
nasa.github.io › fprime › Tutorials › CrossCompilationSetup › CrossCompilationTutorial.html
F´ Cross-Compilation Tutorial | F´ - NASA - GitHub Pages
Cross-compiling is as easy as building the deployment for a specific platform. For users running on 64-bit arm the platform is called aarch64-linux, and for users on 32-bit arm use arm-hf-linux.
🌐
Acmesystems
acmesystems.it › arm9_toolchain
Install the ARM cross compiler toolchain on your Linux PC
This article illustrates how to install on a Linux PC the complete toolchain to cross compile the Linux Kernel, device drivers and applications for the Acme Systems Linux board. This procedure has been tested on Debian "Bookworm" 12. 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
🌐
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.
🌐
Kali Linux
kali.org › docs › development › arm-cross-compilation-environment
ARM Cross-Compilation | Kali Linux Documentation
July 21, 2025 - Download the Linaro cross-compiler from our Git repository: kali@kali:~$ cd ~/ kali@kali:~$ mkdir -p arm-stuff/kernel/toolchains/ kali@kali:~$ cd arm-stuff/kernel/toolchains/ kali@kali:~$ git clone git://gitlab.com/kalilinux/packages/gcc-ar...
🌐
Suchprogramming
suchprogramming.com › cross-compiling-c-code-for-arm
Such Programming - Cross Compiling C Code for ARM
December 15, 2017 - To build, I’ll use the arm-linux-gnueabi-gcc compiler instead of just gcc. I’ll verify it was indeed for an ARM machine with readelf. Next, to test it, I’ll scp it over to my OpenBMC system, ssh into it and give it a go! There it is! I’ve successfully cross compiled a simple program to run on an ARM machine.
🌐
OpenCV
docs.opencv.org › 4.x › d0 › d76 › tutorial_arm_crosscompile_with_cmake.html
OpenCV: Cross compilation for ARM based Linux systems
Cross compilation tools for ARM: gcc, libstc++, etc. Depending on target platform you need to choose gnueabi or gnueabihf tools.
🌐
Linux.com
linux.com › home › training and tutorials › cross-compiling for arm
Cross-compiling for ARM - Linux.com
July 27, 2011 - In order to do program in ARM board [9TDMI], I cross-compiled using the Linux ‘C’ compiler for ARM and here is the procedure that I used. The sources I used are as follows: Binutils – v2.19.1 Linux Kernel -v2. 4. 17 ARM Kernel patch -v2. 4. 17 gcc- v4.5.1 mpc [supporting package for gcc] …
🌐
LinkedIn
linkedin.com › pulse › cross-compiling-gcc-toolchain-arm-cortex-m-processors-ijaz-ahmad
Cross-Compiling GCC Toolchain for ARM Cortex-M Processors
March 14, 2019 - As we are compiling for bare-metal code so no system-call is required. Now that C-Libraries (newlib) is cross-compiled successfully; it's time to add its support to the earlier build gcc compiler to complete it. cd ~/toolchain/build/gcc-build ../../gcc-6.4.0/configure --target=arm-none-eabi --prefix=/home/linuxlite/arm-none-eabi --with-cpu=cortex-m4 \ --enable-languages=c,c++ --with-newlib --with-no-thumb-interwork --with-mode=thumb
🌐
Rust Programming Language
users.rust-lang.org › help
Cross compiling arm - help - The Rust Programming Language Forum
July 5, 2023 - Hi, I'm trying to cross compile raylib(essentially glfw w/ extras) from my host x86 archlinux to arm64 linux /usr/lib/gcc/aarch64-linux-gnu/13.1.0/../../../../aarch64-linux-gnu/bin/ld: cannot find -lX11: No such file or directory collect2: error: ld returned 1 exit status ^ with cargo build --target aarch64-unknown-linux-gnu , I presume I need the arm64 version of x11 installed or something? and the following is done with cross --- stderr CMake Error at /usr/local/share/cmake-3....
🌐
Raspberry Pi Forums
forums.raspberrypi.com › board index › using the raspberry pi › troubleshooting
Cross compilation with ARM toolchain - Raspberry Pi Forums
I don't know how difficult it is - I build the latest versions of some OSS and it usually "just works" - but a core library like glibc might suffer some bootstrapping challenges, especially via cross compilation. Even if painful, it might be an easier path than lobbying for the update in Raspberry Pi OS. ... You can install the Linaro cross-toolchain that was configured with GLIBC 2.31, it's version 10.2-2020.11 which can be found at https://developer.arm.com/downloads/-/gnu-a, once I installed this chain then when I cross compiled my code and took it over to the Raspberry Pi it executed with no issues.
🌐
TutorialsPoint
tutorialspoint.com › article › compiling-native-gcc-for-arm-using-cross-compiler
Compiling native GCC for arm using cross-compiler
March 3, 2023 - Cross-compiling is the process of compiling a program for a different system than the one it is being compiled on. It is typically done to target embedded systems or compile for a different architecture than the host system.