为android编译c程序

时间:2014-06-11 11:17:58

标签: android c linux adb

我有用C编写的hello world程序,我用

编译它
arm-linux-androideabi-gcc hello.c -o hello

通过使用adb将其推送到Android设备来运行它

adb push hello /system
adb shell chmod 777 /system/hello
之后我尝试在adb shell中运行hello binary,但是它说

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

有人可以帮我吗?

Hello world program

#include <stdio.h>

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

1 个答案:

答案 0 :(得分:1)

当您的程序依赖于缺少的库时会发生这种情况。你的构建环境是否正确设置为使用android bionic libc?

尝试将二进制文件推送到/ system / bin而不是/ system。并且在没有./前缀的情况下调用你的二进制文件。

尝试将权限更改为更加严格的日光浴,例如744或755。

如果仍然没有,请查看此主题: https://askubuntu.com/questions/73491/no-such-file-or-directory-for-existing-executable