Skip to main content

build-binary-for-arm

Date created: 2024-10-01

Description

To build binaries for the ARM architecture, and run them on an x86 based processor inside of linux, we need to set up an environment involving some specialised tools.

Prerequisites

  • qemu (qemu-user)
  • gcc-arm-linux-gnueabihf

Setup

  • Install the required tools
$ sudo apt install build-essential gcc-arm-linux-gnueabihf qemu-user
  • Assemble the target code using the cross-compiler
$ arm-linux-gnueabihf-gcc -o <binary-name> <source-code.c> -static
  • Run the programme
$ qemu-arm <./binary-name>