How to compile C into an executable binary file and run it in Android from Android Shell?

后端 未结 5 1971
闹比i
闹比i 2020-11-28 03:25

I have a Device on which I installed Android Gingerbread 2.3.4 Here i want to run C executable file on android device

I am able to run android NDK application on thi

5条回答
  •  南方客
    南方客 (楼主)
    2020-11-28 04:02

    The best/easiest place to put a executable is /data/local. You'll also need to chmod the binary as executable. Often you'll also need to do this in two steps to get the binary from /sdcard/ to /data/local:

    $ adb push mybin /sdcard/
    $ adb shell
    $ cp /sdcard/mybin /data/local/mybin
    $ cd /data/local
    $ chmod 751 mybin
    

    Caveats:

    • Not all systems have cp. You can use cat if this is the case:

      $ cat /sdcard/mybin > /data/local/mybin

    • Some systems don't allow write in /data/local for the "shell" user. Try /data/local/tmp

提交回复
热议问题