I am trying to build dnsmasq DNS filter on Android (LineageOS). This is what I am doing:
I download the code from here:
https://thekelleys.org.uk/dnsmasq/
I downloaded the Android NDK. Then I export the necessary variables:
export NDK_PROJECT_PATH=/home/myuser/Library/Projects/dnsmasq-Android/android-ndk-r26b/
export ANDROID_NDK=/home/myuser/Library/Engineering/manuals/Android/dnsmasq/android-ndk-r26b/
export PATH=$ANDROID_NDK/toolchains/llvm/prebuilt/linux-x86_64/bin:$PATH
Now I am ready to compile. So I run:
../android-ndk-r26b/prebuilt/linux-x86_64/bin/make clean
../android-ndk-r26b/prebuilt/linux-x86_64/bin/make ARCH=arm64-v8a
Now it compiles fine. So I copy the executable to the phone:
adb push dnsmasq /data/local/tmp/dnsmasq
adb shell 'chmod +x /data/local/tmp/dnsmasq'
adb shell '/data/local/tmp/dnsmasq --version'
When I run the last command, I get the error:
/system/bin/sh: /data/local/tmp/dnsmasq: not executable: 64-bit ELF file
What is going wrong? I tried replacing the make architecture with 'arm64', 'arm64,v7a' but did not make a difference..
file
and/orreadelf
command regarding which platform /CPU architecture the executable is targeting. – Robert Mar 03 '24 at 11:53file dnsmasq
gives this:dnsmasq: ELF 64-bit LSB pie executable, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, BuildID[sha1]=2957f2a589e1b2e1d7ab9c97a89c9121a6bcd5f4, for GNU/Linux 4.4.0, not stripped
I have no experience with Android so I can't tell what's wrong about it.. – ellat Mar 03 '24 at 19:41prebuilt
is the target tag thus it is no surprise you compiled the binary forx86_64
and not for arm64-v8a. – Robert Mar 03 '24 at 21:22