0

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..

ellat
  • 1
  • 1
  • Before uploading the binary to the phone you can test the binary using file and/or readelf command regarding which platform /CPU architecture the executable is targeting. – Robert Mar 03 '24 at 11:53
  • Thank you. file 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:41
  • As you can see you have built a 64bit version but not for arm but for x86. I am not a compiler expert but according to this site the first path after prebuilt is the target tag thus it is no surprise you compiled the binary for x86_64 and not for arm64-v8a. – Robert Mar 03 '24 at 21:22
  • Thanks. I'm sorry but I still can't find the solution for this particular problem.. I found these instructions: https://developer.android.com/ndk/guides/other_build_systems#non-autoconf_make_projects But none helped.. – ellat Mar 04 '24 at 19:30

0 Answers0