We can’t run our Arm binary on an x84_64 architecture because instructions are encoded differently on these two architectures. hello64: cannot execute binary file: Exec format error aarch64-linux-gnu-gcc -static -o hello64 hello.cīut what happens if we run this Arm executable on a different architecture? Executing it on an x86_64 architecture would normally result in an error telling us that the binary file cannot be executed due to an error in the executable format./hello64īash. To compile the code as a static executable, we can use aarch64-linux-gnu-gcc with the -static flag. Return printf("Hello, I'm executing ARM64 instructions!\n") Once installed, create a file containing a simple C program for testing, e.g.
QEMU ARM EMULATOR INSTALL
Let’s start with Arm64 and install the following packages: sudo apt update -y & sudo apt upgrade sudo apt install qemu-user qemu-user-static gcc-aarch64-linux-gnu binutils-aarch64-linux-gnu binutils-aarch64-linux-gnu-dbg build-essential In order to compile our code for the Arm architecture, we need to use a cross-compiler. However the GCC compiler you have on your system compiles your code for the architecture of the system it runs on, in this case x86_64. Since processors don’t understand high-level source code directly, we need to convert our C code into machine-code using a compiler. FYI: In this tutorial, I’m using an Ubuntu 20.04.1 LTS VM as a host system.