2

So adb shell gives one a linux terminal into an android phone, when it is connected to a computer. One can run all the standard linux commands like ls and cat inside the android phone, and explore the android filesystem using the adb shell.

Now I wonder, is it possible to use a C/C++ compiler such as clang or gcc to compile and execute a C/C++ program in the android phone, as on linux? I am not talking about android app development here, I mean a linux command line C/C++ program for android. Also, can I use the C standard library and linux system calls such as fork(), exec(), kill(), and working with file descriptors, in the android adb shell, just as I would do it on linux?

Galaxy
  • 2,363
  • 2
  • 25
  • 59
  • 1
    Related: [Running own executable on Android shell](https://android.stackexchange.com/q/45554/3573) and [How to build an executable for Android shell](https://stackoverflow.com/q/35231168/295004) – Morrison Chang Aug 22 '21 at 18:40
  • @MorrisonChang Can you give me any information about possibility to run c/c++ linux system calls in android using these methods you linked here? – Galaxy Aug 22 '21 at 19:47
  • 1
    Perhaps what you are looking for: [Does the Android NDK support most UNIX system calls?](https://stackoverflow.com/q/10626034/295004). Realize that if you want a linux user-like environment to run on the phone, see: [Termux](https://termux.com/) *Usual disclaimer that software recommendations are off-topic here* – Morrison Chang Aug 22 '21 at 20:14
  • @MorrisonChang Thank you sir. I believe that you answered my questions. – Galaxy Aug 22 '21 at 20:25

1 Answers1

1

Yes. You can . For that you need copy your compiler exe's to android file system. From there you can easily call. Same time make sure that all pre-builed libs in android PATH folder.