How to run C++ application in Android SHELL

后端 未结 2 1956
我寻月下人不归
我寻月下人不归 2021-02-08 12:44

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 a

相关标签:
2条回答
  • 2021-02-08 12:50

    If you have rooted your phone you can do a mount -o remount,rw /mnt/sdcard and it should run.

    I've tried it on my Android.

    0 讨论(0)
  • 2021-02-08 13:12

    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.

    The easiest is to move the file to /data/local/tmp/ and execute it using the full path (usual POSIX PATH semantics).

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

    0 讨论(0)
提交回复
热议问题