Android:无法在同一手机上执行通过 Linux Deploy 编译的文件

标签 android linux adb

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

您好!

我在 Linux Deploy 上使用 gcc 进行编译,据我所知,它会将 Ubuntu 和 chroots 下载到环境中。该文件在此 chroot 环境中运行良好。

据我所知,当文件与机器的架构不匹配时会出现此错误。但它是在同一台机器上运行的!有谁知道为什么会这样?


文件权限、所有权和上下文:

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

ID输出:

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

使用/system/bin/sh

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

试图执行一个不存在的文件:

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

最佳答案

你应该用 gcc '-static' 键编译你的二进制文件。如果你不这样做,你的二进制文件将需要动态链接器 ld.so,它在 Android 上不存在(但肯定存在于你的 chroot 中!)。这意味着奇怪的错误消息“没有这样的文件或目录”。

关于Android:无法在同一手机上执行通过 Linux Deploy 编译的文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47407680/

相关文章:

android - FlutterView 未在 Android 中显示 Widget UI

android - NoSuchMethodError : libcore. io.IoUtils.closeQuietly 使用 URLConnection 时

linux - `set -o errtrace` 在 shell 脚本中做什么?

android - 权限拒绝 : runUninstall from pm command asks to run as user -1 but is calling from user 0;

Android:错误属性已被定义

android - 在本地 Android 应用程序的 map 上显示 KML 图层最佳实践

linux - 获取时区日期命令行linux

linux - 如何使 .bashrc 中的更改在当前终端中生效

android - 如何使用 adb 将文件复制到可从 PC 访问的 android 目录

仅当文件不存在或已更改时才推送 adb