I want to run hello world
written on C++ and compiled with Android toolchain 9
, but I faced with issue: by default I have no permissions to launch it and I can't change permissions using chmod`.
我想运行用c++编写、用Android toolchain 9编译的hello world,但我面临的问题是:默认情况下,我没有启动它的权限,也不能使用chmod '修改权限。
I used Android 2.3.3 - Api Level 10
我使用了Android 2.3.3 - Api级别10
Application was compiled by cross compiler for API level 9
应用程序由API 9级的交叉编译器编译
Procedure:
过程:
Compile application:
编译应用程序:
~/toolchain_andr9/bin/ arm-linux-androideabi-g++ helloworld.cpp
~ / toolchain_andr9 / bin / arm-linux-androideabi-g + + helloworld.cpp
Then send application to SDCARD on the emulator:
然后将应用程序发送到模拟器上的SDCARD:
>adb push a.out /mnt/sdcard
then go to SHELL and try to run a.out
:
然后去壳牌,试着跑a。out:
>adb shell
>
>/mnt/sdcard/a.out
And result is:
结果是:
>`/mnt/sdcard/a.out: permission denied`
command ls -l
shows rights for a.out
:
命令ls -l显示a.out的权利:
>`----rwxr-x system sdcard_rw 863656 2012-04-12 22:42 a.out`
I tried to change permissions:
我尝试改变权限:
>chmod 777 /mnt/sdcard/a.out
But rights don't change:
但权利不改变:
>`----rwxr-x system sdcard_rw 863656 2012-04-12 22:42 a.out`
I think I have left some important thing using android.
我想我在android上留下了一些重要的东西。
Could anybody help me and give me a way how to run application in `Android SHELL?
谁能帮我一个忙,告诉我如何在“Android SHELL”中运行应用程序?
Thanks a lot.
非常感谢。
P.S. sorry for my English =)
对不起,我的英语不好。
2 个解决方案
#1
13
By default, the SD card is mounted with option noexec
, that disallows the execution of any file on the card, no matter what it's permissions(even -rwxrwxrwx
), so you need to move the file to another location and then execute it.
默认情况下,SD卡上安装了选项noexec,这将禁止在该卡上执行任何文件,无论该文件具有何种权限(甚至是-rwxrwxrwx),因此您需要将该文件移动到另一个位置,然后执行它。
The easiest is to move the file to /data/local/tmp/
and execute it using the full path (usual POSIX PATH semantics).
最简单的方法是将文件移动到/data/local/tmp/并使用完整路径(通常是POSIX路径语义)执行它。
> adb push a.out /data/local/tmp/a.out
> adb shell
> chmod 755 /data/local/tmp/a.out
> /data/local/tmp/a.out
This does not require root access and survives reboot.
这并不需要root访问并在重新启动后继续运行。
#2
4
If you have rooted your phone you can do a mount -o remount,rw /mnt/sdcard
and it should run.
如果你的手机已经根了根,你可以安装-o重新安装,rw /mnt/sdcard,它应该会运行。
I've tried it on my Android.
我在我的安卓系统上试过。
#1
13
By default, the SD card is mounted with option noexec
, that disallows the execution of any file on the card, no matter what it's permissions(even -rwxrwxrwx
), so you need to move the file to another location and then execute it.
默认情况下,SD卡上安装了选项noexec,这将禁止在该卡上执行任何文件,无论该文件具有何种权限(甚至是-rwxrwxrwx),因此您需要将该文件移动到另一个位置,然后执行它。
The easiest is to move the file to /data/local/tmp/
and execute it using the full path (usual POSIX PATH semantics).
最简单的方法是将文件移动到/data/local/tmp/并使用完整路径(通常是POSIX路径语义)执行它。
> adb push a.out /data/local/tmp/a.out
> adb shell
> chmod 755 /data/local/tmp/a.out
> /data/local/tmp/a.out
This does not require root access and survives reboot.
这并不需要root访问并在重新启动后继续运行。
#2
4
If you have rooted your phone you can do a mount -o remount,rw /mnt/sdcard
and it should run.
如果你的手机已经根了根,你可以安装-o重新安装,rw /mnt/sdcard,它应该会运行。
I've tried it on my Android.
我在我的安卓系统上试过。