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 - If nothing else it gives you the ... 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 ...
🌐
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.
Discussions

Does anyone here cross compile for arm64 musl? do you get frequent issues doing it?
I tried Gentoo, T2SDE and Void for this about a year ago and had issues on all 3. Can't say I put a great deal of effort in but after a few failures of each I shelfed the idea for while. Alpine seemed the most robust as they only really target musl. More on reddit.com
🌐 r/Gentoo
9
5
July 2, 2023
gcc - cross-compile for ARM64, understanding make TARGET=aarch64 - Stack Overflow
I'm trying to cross-compile a library for ARM64, I'm using Ubuntu 18.04 x86_64 host system for a build and the way I'm doing the cross-compile as sudo apt-get update sudo apt-get install crossbuild- More on stackoverflow.com
🌐 stackoverflow.com
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
Instructions on how to cross compile Windows (amd64 -> arm64)
Since this was a rather annoying ... 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 vcvarsamd64_arm64.bat): & 'C:\Program ... More on github.com
🌐 github.com
5
January 26, 2024
🌐
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:
🌐
Microsoft Learn
learn.microsoft.com › en-us › dotnet › core › deploying › native-aot › cross-compile
Cross-compilation - .NET | Microsoft Learn
May 27, 2025 - Cross-compiling from x64 Windows to ARM64 Windows or vice versa works as long as the appropriate VS 2022 C++ build tools are installed. To target ARM64 make sure the Visual Studio component "VS 2022 C++ ARM64/ARM64EC build tools (Latest)" is ...
🌐
GitHub
github.com › abhiTronix › raspberry-pi-cross-compilers › wiki › 64-Bit-Cross-Compiler:-Installation-Instructions
64 Bit Cross Compiler: Installation Instructions
September 7, 2024 - These ARM64 Toolchains can be used on any Linux Distributions (32-bit/64-bit) for cross-compiling programs for any Raspberry Pi 64-Bit OS flavors with 64-bit kernel only (such as Raspberry Pi OS (64-bit)).
Author   abhiTronix
🌐
Reddit
reddit.com › r/gentoo › does anyone here cross compile for arm64 musl? do you get frequent issues doing it?
r/Gentoo on Reddit: Does anyone here cross compile for arm64 musl? do you get frequent issues doing it?
July 2, 2023 -

I get frequent issues doing it, and I wonder if its just how things are, or if theres something I can do to make it better.

I tried to cross compile portage packages on a amd64 glibc as a binhost thing for the aarch64-musl target. I did this by creating a musl chroot on the amd64 system.

Initially, I could not even get the cross chain to do anything. I eventually figured it out and filed a bug report here https://bugs.gentoo.org/909453

But still, many packages failed compilation. I figured this may be the reality of cross compiling, so I still installed on the arm64 system the ones that did not fail cross compile, But now it does not connect to the internet and can no longer ssh to it (debugging at the moment)

Is this a frequent occurrence with this kind of setup? Am I better off switching away from musl, or is this just amd64 to arm64 issue?

Top answer
1 of 4
3
I tried Gentoo, T2SDE and Void for this about a year ago and had issues on all 3. Can't say I put a great deal of effort in but after a few failures of each I shelfed the idea for while. Alpine seemed the most robust as they only really target musl.
2 of 4
1
I'm not using musl, but I am cross-compiling for an ARM64 system on an AMD64. In general I would say that cross-compilation works reliably for @system, and the other critical packages to get a system online, but after that it gets flaky. It's not a lot of packages that have problems, but it doesn't take that many to make it a real pain and impractical to do on an ongoing basis. I had some binaries get build for the wrong architecture. I had libs get pulled in from the main system. There really isn't a clean solution for cross-compilation on gentoo with clang or rust. You can cobble something together but it's messy and brittle. There's a lot of odd little problems that pop up. I was able to work around most of them eventually, but it's a hassle. What DOES work reliably is to set up binfmt_misc qemu emulation, then chroot into the environment and run builds there. This way the build is "native". You have to tweak the /etc/portage/make.conf of course, since it's set up to work with / in a different place if you built the image via crossdev in the first place. The build is slow enough that it's not necessarilly helpful for speed compared to the target, but if your target has limited ram it's still a big win. It's a bit slow, but it's reliable, which to me is a lot more valuable. I don't mind waiting hours for something to build as long as it works.
Find elsewhere
🌐
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
The package pkg-config-aarch64-linux-gnu is required for aarch64. 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:
🌐
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
🌐
Arm Learning
learn.arm.com › install-guides › gcc › cross
Cross-compiler | Arm Learning Paths
The Linux package manager downloads the required files. No manual download is needed. You can install a GCC cross compiler with Arm as a target architecture using Linux package managers.
🌐
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......
🌐
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
🌐
Earthly
earthly.dev › blog › cmake-gcc-cross-compile
Using CMake and GCC to Cross-Compile Binaries - Earthly Blog
July 19, 2023 - In this tutorial, you’ll learn how to build a simple C++ program and then cross-compile it for AArch64 or ARM64-based devices using CMake and GCC.
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.

🌐
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):
🌐
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.
🌐
Mlplatform
review.mlplatform.org › plugins › gitiles › ml › armnn › + › refs › heads › experimental › matteo › BuildGuideCrossCompilation.md
How to Cross-Compile ArmNN 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:
🌐
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
🌐
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/ kinetic-updates main restricted deb [arch=arm64] http://ports.ubuntu.com/ kinetic universe deb [arch=arm64] http://ports.ubuntu.com/ kinetic-updates universe deb [arch=arm64] http://ports.ubuntu.com/ kinetic multiverse deb [arch=arm64] http://ports.ubuntu.com/ kinetic-updates multiverse deb [arch=arm64] http://ports.ubuntu.com/ kinetic-backports main restricted universe multiverse sudo apt-get install liblzo2-dev:arm64 etc.