Rahul R Dhobi
Rahul R Dhobi

Reputation: 5806

Compile c program for android

I have hello world program written in C,I'm compiling it using

arm-linux-androideabi-gcc hello.c -o hello

and running it by pushing it to android device using adb

adb push hello /system
adb shell chmod 777 /system/hello

after that I'm trying to run hello binary in adb shell but it says

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

Can anyone help me please?

Hello world program

#include <stdio.h>

int main()
{
    printf("HELLO WORLD\n");
    return 0;
}

Upvotes: 2

Views: 439

Answers (1)

m-ric
m-ric

Reputation: 5901

That happens when your program has a dependency on a missing library. Is your build environment correctly set up to use android bionic libc?

Try to push your binary to /system/bin instead of /system. And call your binary without the ./ prefix.

Try to change the permissions to sunbathing more restrictive like 744 or 755.

If it still does not make it, have a look to this thread: https://askubuntu.com/questions/73491/no-such-file-or-directory-for-existing-executable

Upvotes: 1

Related Questions