I'm have to run SFML C++ code on my Android device, terminal named Termux. I did build all libs for sfml, but can't cross-compile grop.cpp.
I run this command:
bash $NDK/toolchains/llvm/prebuilt/linux-x86_64/bin/aarch64-linux-android29-clang++\
-std=c++14 -Wall -Wextra -Wpedantic -I ~/SFML-2.5.1/include -L ~/SFML-2.5.1/build/lib\
-lsfml-system -lsfml-window -lsfml-graphics grop.cpp -o gorp
But get output error:
/data/data/com.termux/files/home/android-ndk-r25c/toolchains/llvm/prebuilt/linux-x86_64/bin/aarch64-linux-android29-clang++: line 4: /data/data/com.termux/files/home/android-ndk-r25c/toolchains/llvm/prebuilt/linux-x86_64/bin/clang++: cannot execute binary file: Exec format error
I target Android 10, architecture aarch64, supported ABIs: arm64-v8, armeabi-v7 and armeabi.
When I file the cross-compiler:
file $NDK/toolchains/llvm/prebuilt/linux-x86_64/bin/aarch64-linux-android29-clang++ /data/data/com.termux/files/home/android-ndk-r25c/toolchains/llvm/prebuilt/linux-x86_64/bin/aarch64-linux-android29-clang++: Bourne-Again shell script, ASCII text executable
When I file the cross-compiler as binary:
file /data/data/com.termux/files/home/android-ndk-r25c/toolchains/llvm/prebuilt/linux-x86_64/bin/clang++ /data/data/com.termux/files/home/android-ndk-r25c/toolchains/llvm/prebuilt/linux-x86_64/bin/clang++: symbolic link to clang
When I file the actual actual binary:
file $(readlink -f /data/data/com.termux/files/home/android-ndk-r25c/toolchains/llvm/prebuilt/linux-x86_64/bin/clang++) /data/data/com.termux/files/home/android-ndk-r25c/toolchains/llvm/prebuilt/linux-x86_64/bin/clang-14: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, for GNU/Linux 2.6.24, stripped
You installed an LLVM/clang toolchain compiled for amd64
(a/k/a x86_64
) and try to run it on an arm64
(a/k/a aarch64
) system, hence the classical error:
cannot execute binary file: Exec format error
You need to install the proper toolchain for your system.