【问题标题】:Compile c program for android为android编译c程序
【发布时间】:2014-06-11 11:17:58
【问题描述】:

我有一个用 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 二进制文件,但它显示

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

谁能帮帮我?

Hello World 程序

#include <stdio.h>

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

【问题讨论】:

  • 你好像不在正确的目录
  • 你的设备植根了吗
  • @Manül:我在正确的路径中也尝试过使用绝对路径

标签: android c linux adb


【解决方案1】:

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

尝试将二进制文件推送到 /system/bin 而不是 /system。并调用不带 ./ 前缀的二进制文件。

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

如果还是不行,请看这个帖子: https://askubuntu.com/questions/73491/no-such-file-or-directory-for-existing-executable

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-01-03
    • 1970-01-01
    • 2018-06-08
    • 2017-07-14
    相关资源
    最近更新 更多