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

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
Arch Linux ARM • View topic - How to effectively cross compile from x86 for aarch64
I do not want to compile on my ... 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- ..... More on archlinuxarm.org
🌐 archlinuxarm.org
May 24, 2022
Cross-compilation of MLIR runner libraries to ARM on X86 host
Hi, I am trying to cross-compile MLIR runner libraries such as libmlir_runner_utils.so to ARM on a X86_64 host. My clang/llvm/mlir build commands are as follows: cmake -GNinja \ "-H$LLVM_SRC_DIR/llvm" \ "-B$build_dir$suffix" \ -DCMAKE_C_COMPILER=clang-10 \ -DCMAKE_CXX_COMPILER=clang++-10 \ ... More on discourse.llvm.org
🌐 discourse.llvm.org
1
0
January 23, 2022
🌐
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)
🌐
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
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.

🌐
Google
android.googlesource.com › platform › external › armnn › + › refs › heads › upstream-master › BuildGuideCrossCompilation.md
How to Cross-Compile Arm NN on x86_64 for arm64
mkdir x86_64_build cd x86_64_build ../configure --prefix=$HOME/armnn-devenv/google/x86_64_pb_install make install -j16 cd .. Build the arm64 version of the protobuf libraries: mkdir arm64_build cd arm64_build CC=aarch64-linux-gnu-gcc \ CXX=aarch64-linux-gnu-g++ \ ../configure --host=aarch64-linux \ --prefix=$HOME/armnn-devenv/google/arm64_pb_install \ --with-protoc=$HOME/armnn-devenv/google/x86_64_pb_install/bin/protoc make install -j16 cd ..
🌐
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 of the biggest complications is the designation of ARM processors, which determines the necessary dependencies.
Find elsewhere
🌐
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]
🌐
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 ...
🌐
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 ...
🌐
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 - You can cheat with an ARM QEMU virtual machine on your developer machine to do “native” builds that will produce binaries that will run on your target embedded device. Take care to configure the QEMU hardware and the native toolchain that you will be using to match with your target device. Also, be aware that the build speed won’ t be great due to the ARM to x86 translation. But otherwise this is a totally viable option, especially for esoteric packages/build systems that has no support for cross compiling.
🌐
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.
🌐
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.
🌐
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 - I decided we needed to figure out how to build our lambda runtimes from an ARM server: I needed to cross-compile Rust from ARM to x86-64. So here we go. I launched two Ubuntu 20.04 instances: a c6g.medium for the build machine and a t3.micro as an x86-64 to run the results on.
Top answer
1 of 2
3

A minimal and deterministic procedure for assembling a .S file targeting the T32 instruction set on an Ubuntu 22.04 x86_64 machine could be to install the latest Arm toolchain for arm-none-eabi

if you don't have wget installed, just execute: sudo apt-get install wget, or download arm-gnu-toolchain-11.3.rel1-x86_64-arm-none-eabi.tar.xz using a WEB browser into you home directory.

Once done:

cd ${HOME}
# Skip the wget command hereafter if arm-gnu-toolchain-11.3.rel1-x86_64-arm-none-eabi.tar.xz was already downloaded into your home directory.
wget "https://developer.arm.com/-/media/Files/downloads/gnu/11.3.rel1/binrel/arm-gnu-toolchain-11.3.rel1-x86_64-arm-none-eabi.tar.xz?rev=95edb5e17b9d43f28c74ce824f9c6f10&hash=176C4D884DBABB657ADC2AC886C8C095409547C4" -O arm-gnu-toolchain-11.3.rel1-x86_64-arm-none-eabi.tar.xz
tar Jxf arm-gnu-toolchain-11.3.rel1-x86_64-arm-none-eabi.tar.xz

You can now assemble your program using the command:

${HOME}/arm-gnu-toolchain-11.3.rel1-x86_64-arm-none-eabi/bin/arm-none-eabi-gcc -c -mthumb foo.S -o foo.o 

Please note that a file with the .S extension usually requires to be processed using cpp, the C preprocessor - this is why the command is using arm-none-eabi-gcc, and not arm-none-eabi-as.

2 of 2
1

run

sudo sh -c 'apt update;apt install binutils-arm-none-eabi;'

then the code can be compiled with

arm-none-eabi-as -mthumb foo.S -o foo.o

example:

$ echo nop > foo.S 
$ arm-none-eabi-as -mthumb foo.S -o foo.o
$ echo $?
0
$ file foo.o
foo.o: ELF 32-bit LSB relocatable, ARM, EABI5 version 1 (SYSV), not stripped
  • i gathered this from @Nate Eldredge and @old_timer in the comments.