How to run C++ application in Android SHELL

后端 未结 2 1958
我寻月下人不归
我寻月下人不归 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 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.

提交回复
热议问题