Search code examples
androidlinuxadb

Android: cannot execute file compiled through Linux Deploy on the same phone


root@hammerhead:/data/local # ./HelloWorld
tmp-mksh: ./HelloWorld: No such file or directory

Hello!

I compiled using gcc on Linux Deploy, which as I understand downloads Ubuntu and chroots into the environment. The file runs fine inside of this chroot environment.

As I understand this error is given when the file doesn't match the architecture of the machine. But it is running on the same machine! Does anyone know why this may be happening?


File permissions, ownership and context:

-rwxrwxrwx root  root  u:object_r:system_data_file:s0 HelloWorld

Id output:

uid=0(root) gid=0(root) context=u:r:init:s0

Using /system/bin/sh

/system/bin/sh: ./Helloworld: No such file or directory

Trying to execute a non existant file:

/system/bin/sh: ./test: not found

Solution

  • You should compile your binary with gcc '-static' key. If you don't do that, you binary will need dynamic linker ld.so that doesn't exist on Android (but definitely exists inside your chroot!). This implies that strange error message "No such file or directory".