Android:无法在同一部手机上执行通过Linux Deploy编译的文件 [英] Android: cannot execute file compiled through Linux Deploy on the same phone

查看:143
本文介绍了Android:无法在同一部手机上执行通过Linux Deploy编译的文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

你好!

我在Linux Deploy上使用gcc进行了编译,据我所知,它会将Ubuntu和chroots下载到环境中.该文件可以在chroot环境中正常运行.

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输出:

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

使用/system/bin/sh

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

推荐答案

您应使用gcc'-static'键编译二进制文件.如果不这样做,则二进制文件将需要动态链接程序ld.so,因此在Android上不存在(但肯定存在于chroot中!).这意味着出现奇怪的错误消息没有这样的文件或目录".

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".

这篇关于Android:无法在同一部手机上执行通过Linux Deploy编译的文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆