Yes, for C/C++, Go, Rust, and many others. Fwiw, you can also run x86 Linux executables on ARM Linux, and ARM Linux executables on x86 Linux with qemu user mode emulation. This isn't a VM; it's a per-process CPU emulator and JIT compiler. Kernel ABI calls are native, not emulated. https://ownyourbits.com/2018/06/13/transparently-running-binaries-from-any-architecture-in-linux-with-qemu-and-binfmt_misc/ Update: It's more work to set up, but Box64 will give you better performance. Answer from funbike on reddit.com
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....

Discussions

Arch Linux ARM • View topic - How to effectively cross compile from x86 for aarch64
What is the general way to tell makepkg on x86 to compile for aarch64 and how does it work with all the arm dependencies that my package might night during building or to run? I considered the following wiki pages: https://wiki.archlinux.org/title/Cross- ... guidelines Here the wiki tells about ... More on archlinuxarm.org
🌐 archlinuxarm.org
May 24, 2022
linux kernel - Cross compiling for arm from x86 - Stack Overflow
I am trying to insert a .ko kernel module into the linux running in arm processor. I built a .ko file in my desk PC which is a x86 one. How do I cross compile it to arm specs. More on stackoverflow.com
🌐 stackoverflow.com
c++ - How to cross compile linux arm to x86 - Stack Overflow
I tried running ubuntu x86 docker (qemu) and it's super slow - to the point it's unusable. I have linux ubuntu (arm) installed using parallels and would like to compile for x86 target instead of arm. ... I don't know about Apple, but on Linux systems you can typically install a specific cross-co... More on stackoverflow.com
🌐 stackoverflow.com
gcc - Targeting x86 from ARM? - Stack Overflow
Is it possible to compile to x86 using gcc on an ARM machine? I can't find any -march option which would allow this to be done.. if it can't be done, no big deal, but I'm still interested to know if it's possible. ... Yes, but you don't want a -march machine. You want to build or install a cross compiler with arm as the host architecture and x86 as the target architecture. Typically (assuming a linux os) you might get binaries like x86_64-linux-gnu-gcc for ... More on stackoverflow.com
🌐 stackoverflow.com
🌐
96Boards
96boards.org › documentation › guides › crosscompile › commandline.html
Cross Compile files on x86 Linux host for 96Boards ARM systems - 96Boards
Linux host system is used as the cross compiling station · Examples were tested on fully updated Ubuntu 15.04 and 16.04 releases · Examples depend on matching, latest libsoc and libmraa libraries to be installed on both devices (x86 machine, ARM machine)
🌐
Arch Linux ARM
archlinuxarm.org › forum › viewtopic.php
Arch Linux ARM • View topic - How to effectively cross compile from x86 for aarch64
May 24, 2022 - ... that was my original question, if you know how to cross compile (but with makepkg, I do want arch .pkg.* files in the end), feel free to guide me ... Install distcc and a cross compiler on the fast host, use the SBC (you don't even need to compile on the ARM, just use the fast machine of ...
🌐
GitHub
github.com › CGAL › cgal › wiki › Linux-X86-ARM-Cross-Compilation
Linux X86 ARM Cross Compilation
May 31, 2019 - CGAL is now ready to be used with an arm application. ... If you omit -DCGAL_test_cpp_version_RUN_RES__TRYRUN_OUTPUT=201103L, you will have to run cmake twice.. The options -DCMAKE_CXX_FLAGS=-std=c++11 -DCGAL_test_cpp_version_RUN_RES=0 -DCGAL_test_cpp_version_RUN_RES__TRYRUN_OUTPUT=201103L allow to use the C++11 standard. When CGAL is compiled with a C++11 compiler, the library Boost.Thread is no longer required, and Boost libraries can be used header-only.
Author   CGAL
🌐
Quora
quora.com › How-can-we-compile-the-x86-target-binaries-on-an-ARM-computer-from-C-C-source-code-Is-there-any-compilers-or-solutions-to-do-that
How can we compile the x86 target binaries on an ARM computer from C/C++ source code? Is there any compilers or solutions to do that? - Quora
Answer (1 of 4): Just install a cross-compiler that can target x86. Concretely, for example, in Ubuntu 20.04 running on aarch64: [code]$ uname -m aarch64 $ sudo apt install gcc-i686-linux-gnu [/code]
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.

Find elsewhere
🌐
FIRMWARE DEVELOPER
firmcodes.com › home › how to cross compile for arm
How to cross compile for ARM
February 10, 2017 - Now if u are scared that ohhh !!! what is my output …I want to see it on my system before running on the target system….okkk u can do it.. For this u should install a tool “qemu” for setting the environment for arm on your x86 plateform.
🌐
Luis Llamas
luisllamas.es › inicio › programación
How to cross compile C++ for ARM from an X86/X64 computer
November 13, 2021 - Today we are going to see how to compile a C++ application for an ARM processor from a computer with x86 or x64 architecture. To do this, first, we must install the necessary dependencies. sudo apt-get install libc6-armel-cross libc6-dev-armel-cross binutils-arm-linux-gnueabi libncurses5-dev build-essential bison flex libssl-dev bc ... Next, we install the appropriate version of G++ for our ARM architecture. One ...
🌐
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 - It’s not always possible to build directly on these ARM-based devices, especially when they are limited in resources. The majority of build and developer machines are still on x86 and by using cross compiling, it is possible to build binaries or executables usable on another architecture.
🌐
Google
android.googlesource.com › platform › external › armnn › + › refs › heads › upstream-master › BuildGuideCrossCompilation.md
How to Cross-Compile Arm NN on x86_64 for arm64
sudo apt-get install libssl-dev wget https://github.com/Kitware/CMake/releases/download/v3.19.0-rc3/cmake-3.19.0-rc3.tar.gz tar -zxvf cmake-3.19.0-rc3.tar.gz cd cmake-3.19.0-rc3 ./bootstrap --prefix=$HOME/armnn-devenv/cmake/install make all install cd.. ... Get protobuf from here: https://github.com/protocolbuffers/protobuf: (Requires Git if not previously installed: sudo apt install git) git clone -b v3.12.0 https://github.com/google/protobuf.git protobuf cd protobuf git submodule update --init --recursive ./autogen.sh · Build a native (x86_64) version of the protobuf libraries and compiler (protoc): (Requires cUrl, autoconf, llibtool, and other build dependencies if not previously installed: sudo apt install curl autoconf libtool build-essential g++)
🌐
Arm Learning
learn.arm.com › install-guides › gcc › cross
Cross-compiler | Arm Learning Paths
GCC is used to cross-compile Linux applications targeting Arm. Applications can be compiled for 32-bit or 64-bit Arm Linux systems. The executables for 32-bit are arm-linux-gnueabihf-gcc and arm-linux-gnueabihf-g++. The executables for 64-bit ...
🌐
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 - The classic example for cross compiling ... from a powerful x86–64 PC. Cross compiling is preferred here because it is orders of magnitude faster to do so than building natively on the embedded device....
🌐
Bryan Burgers
burgers.io › cross-compile-rust-from-arm-to-x86-64
Cross-compiling Rust from ARM to x86-64 | Bryan Burgers
July 14, 2020 - $ scp target/x86_64-unknown-linux-musl/release/crossed ubuntu@target-machine:. $ ssh ubuntu@target-machine ./crossed 200 ... As bullet points? Why not. Make sure CC_x86_64_unknown_linux_musl is permanently in your environment somehow. For us, this involved adding it to the environment section for self-hosted GitHub runners. In my specific testing for our specific projects, compilation times were up to about 10% slower than on a corresponding c5 instance. But the cost tradeoff was worth it. I'm holding out hope that AWS will give us ARM-based lambdas in the future.