The advantage of using a POSIX based mobile OS is that you can run and install any Linux applications on your mobile (smartphone) with ease. And thanks to Open Source, its even easier to Compile, Install & Run Linux Applications on Android.
To get basic Linux apps running on Android, you need BusyBox. To give you some background, BusyBox is a software application that provides many standard Unix tools, much like the larger (but more capable) GNU Core Utilities. BusyBox is designed to be a small executable for use with the Linux kernel, which makes it ideal for use with embedded devices. It has been self-dubbed “The Swiss Army Knife of Embedded Linux”.
Using this guide, you’ll be able to:
- Compile Linux C, C++ app directly on Android
- Install, Run Linux apps on Android.
How to Compile, Run Linus Apps on Android
Step 1. Install BusyBox from Play Store (requires root). If you don’t have Root access, you can follow steps mentioned in the video which involves adb push for busybox binary to /data/ and setting permissions.
BusyBox would allow you to install various Linux apps on Android coz BusyBox is bundled with all the runtime dependecies.
Step 2. To make your environment even more capable, lets go ahead and install BostBrew Basil from Play store.
BostBrew Basil bootstraps the base system and do some basic package management by using uses Dpkg and Apt instead of Opkg. This will let you install various linux packages, this is where BostBrew shines.
Step 3. Install Linux apps using APT Package manager
To install apps using apt package manager, all you need to do is:
apt-get install gcc g++
This will install gcc, g++ compilers and you can specify any other package name and ARM version should be automatically installed to your android.
Step 4. Compiling C, C++ source code on Android
Compile any source file using g++ and run it:
That’s it. You’ve successfully compiled and run your own C code.
You can watch the video below, it essentially covers the same steps in an easy to follow tutorial: