Running "make distclean" first solved it.

./configure --host=aarch64-linux-gnu --prefix=/opt/install-arm64/papi-5.6.1.0 --with-ffsll --with-walltimer=cycle --with-tls=__thread --with-virtualtimer=perfctr --with-perf-events --with-arch=aarch64 --with-CPU=arm

make

sudo make install

To install those binary files in /opt/install-arm64/papi-5.6.1.0.

Answer from LuisM on Stack Overflow
🌐
FreeBSD
forums.freebsd.org › development › userland programming and scripting
C - How to cross-compile ARM64 binary (custom code) from x64 system | The FreeBSD Forums
June 13, 2023 - You can also bless your arm64 binaries under amd64, which allows you to run aarch64 executables while actually operating under amd64. This worked for me, for example: https://forums.freebsd.org/threads/raspberry-pi-3-and-poudriere.63470/ ... A little bit off the path but these are some things to consider: 1) use a Makefile! If nothing else it gives you the opportunity to supply configuration and target params in a more generic manner 2) set up a crossbuild toolchain on your platform such that the CC CXX CROSS_COMPILE commands are executed as $(CROSS_COMPILE)$(CC) in the Makefile 3) CROSS_COMPILE is generally the prefix name of the platform compiler of your target: such as CROSS_COMPILE=arm-gnueabi-hf- so that the Makefile sees it as arm-gnueabi-hf-cc when CROSS_COMPILE is set.
🌐
Google
android.googlesource.com › platform › external › armnn › + › refs › heads › upstream-master › BuildGuideCrossCompilation.md
How to Cross-Compile Arm NN on x86_64 for arm64
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++) 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:
Discussions

android - Cross-compiling for arm64 - Stack Overflow
I'm trying to install papi tools on juno arm development board, I have installed 64-bit Linaro `ack-armlt' Android Common Kernel plus Android filesystem on that board (I followed this tutorial to More on stackoverflow.com
🌐 stackoverflow.com
Instructions on how to cross compile Windows (amd64 -> arm64)
Since this was a rather annoying ... (still haven't tried to consume but even getting an output is a win) an arm64 static openblas library on windows amd64. Load into the appropriate cross compiling developer shell (in my case powershell but for cmd.exe it would be ... More on github.com
🌐 github.com
5
January 26, 2024
how can I cross compile an assembly and a .c file to arm64 on macos?
Compile boot.S with this command “clang -target aarch64 -c boot.S” then Compile kernel.c with this command “clang -target aarch64 -c kernel.c” then link them with linker using -T option to specify linker script file with both object file. More on reddit.com
🌐 r/C_Programming
17
4
May 28, 2025
c++ - Cross-compile to ARM64 (AARCH64) on Intel 64-bit Red Hat 7.5 can't find dlfcn.h, cstddef.h, etc - Stack Overflow
I have a program that compiles in gcc fine on Red Hat 64-bit Linux. I run and it works perfectly fine to make a shared object file: gcc -ansi -std=c++11-shared -fPIC...etc I am trying to cross-co... More on stackoverflow.com
🌐 stackoverflow.com
🌐
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 - For example, to use your standard PC, most likely x86, to build something that is usable on another machine or device that’s on another architecture, like ARM. In this post, I’ll explain how to do cross compiling for 32bit ARM (arm) or 64bit ARM (aarch64) using Debian 10 or Ubuntu 20.04 LTS.
🌐
Earthly
earthly.dev › blog › cmake-gcc-cross-compile
Using CMake and GCC to Cross-Compile Binaries - Earthly Blog
July 19, 2023 - The first line sets the minimum version of CMake required to build this project to version 3.0. The second line sets the project name to Hello, and the following two lines set the target system name and processor architecture. The target system is Linux, and the target processor is aarch64 (ARM64). The following two lines set the C and C++ compilers to be used for cross-compiling the code to the target system.
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.

🌐
DPDK
doc.dpdk.org › guides-19.11 › linux_gsg › cross_build_dpdk_for_arm64.html
4. Cross compile DPDK for ARM64 — Data Plane Development Kit 19.11.14 documentation
To install it in Ubuntu: ... To configure a build, choose one of the target configurations, like arm64-dpaa-linux-gcc and arm64-thunderx-linux-gcc. ... To cross-compile, including the kernel modules, the kernel source tree needs to be specified by setting RTE_KERNELDIR:
Find elsewhere
🌐
Ask Ubuntu
askubuntu.com › questions › 1410508 › cross-compiling-for-arm64-on-amd64-architecture
64 bit - Cross compiling for arm64 on amd64 architecture - Ask Ubuntu
May 25, 2022 - I don't think you should be installing packages like build-essential:arm64 at all - you should be using the native (i.e. amd64) cross compiler toolchain packages like gcc-aarch64-linux-gnu. See for example this introduction Cross compiling for arm or aarch64 on Debian or Ubuntu
🌐
GitHub
gist.github.com › lategoodbye › c7317a42bf7f9c07f5a91baed8c68f75
Raspberry Pi: How to cross-compile and use Mainline Kernel · GitHub
Move into the repository folder and setup cross-compiler (for ARM 64-bit replace ARCH=arm with ARCH=arm64):
🌐
Arm Learning
learn.arm.com › install-guides › gcc › cross
Cross-compiler | Arm Learning Paths
GCC is open source and freely available for use. To confirm the installations are successful, enter: aarch64-linux-gnu-gcc --version arm-linux-gnueabihf-gcc --version · To cross-compile an example program, create a text file named hello-world.c with the contents below.
🌐
GitHub
github.com › uablrek › cross-compile
GitHub - uablrek/cross-compile: Howto cross-compile on Linux for arm64 (aarch64) · GitHub
Cross compile is often non-trivial, but not so hard as you might think. This repo describes how to cross compile to the ARM64 architecture (aarch64), for example to RPi 4 and Radxa Rock 4se SoC boards.
Author   uablrek
🌐
GitHub
github.com › OpenMathLib › OpenBLAS › issues › 4459
Instructions on how to cross compile Windows (amd64 -> arm64) · Issue #4459 · OpenMathLib/OpenBLAS
January 26, 2024 - Invoke the following CMake, based primarily on the example for arm64 -> arm64 in the wiki: cmake .. -G Ninja -DCMAKE_BUILD_TYPE=Release -DDYNAMIC_ARCH=0 -DTARGET=ARMV8 -DCMAKE_CROSSCOMPILING=ON -DCMAKE_SYSTEM_NAME="Windows" -DARCH=arm64 -DBINARY=64 -DCMAKE_SYSTEM_PROCESSOR=ARM64 -DCMAKE_C_COMPILER=clang-cl -DCMAKE_C_COMPILER_TARGET=arm64-pc-windows-msvc -DCMAKE_ASM_COMPILER_TARGET=arm64-pc-windows-msvc.
Author   OpenMathLib
🌐
DPDK
doc.dpdk.org › guides › linux_gsg › cross_build_dpdk_for_arm64.html
4. Cross compiling DPDK for aarch64 and aarch32 — Data Plane Development Kit 26.03.0 documentation
To cross-compile DPDK on a desired ... we can use the following command, provided the cross file has been modified accordingly: meson setup aarch64-build-gcc --cross-file config/arm/arm64......
🌐
96Boards
96boards.org › documentation › guides › crosscompile › commandline.html
Cross Compile files on x86 Linux host for 96Boards ARM systems - 96Boards
... Create a file using your prefered editor named aarch64.cmake - This example will use vim text editor. ... This file will tell the cmake build system that it is to cross compile the code and to use the cross compile toolchain.
🌐
Kodi Forum
forum.kodi.tv › showthread.php
Cross compiling to aarch64
January 10, 2023 - I can get my system to find these libraries on the compile device (x86_64) by doing this: sudo dpkg --add-architecture arm64 sudo touch /etc/apt/sources.list.d/arm-cross-compile-sources.list deb [arch=arm64] http://ports.ubuntu.com/ kinetic main restricted deb [arch=arm64] http://ports.ubuntu.com/ ...
🌐
Stack Overflow
stackoverflow.com › questions › 62139412 › cross-compile-for-arm64-understanding-make-target-aarch64
gcc - cross-compile for ARM64, understanding make TARGET=aarch64 - Stack Overflow
sudo apt-get update sudo apt-get install crossbuild-essential-arm64 ... FYI. I'm trying to follow TensorFlow cross-compile for ARM64 and set the latest GNU Toolchain for ARM64.