Native C programs for ARM based Android phones
I wrote this small code to test and saved as count.c ,
#include <stdio.h>
int main()
{
int x=0;
for(x=0;x<11;x++){
printf("%i\n",x);
}
}
Then I compiled it using following command in command prompt,
D:\>arm-linux-gnueabihf-gcc count.c -o count -static
The I copied the binary file to mobile using ADB (Android Debug Bridge), you can do it using a file manager too. Make sure to put the compile binary to /system because you can execute binaries only at there in android system.
D:\>adb push count /system
3049 KB/s (463524 bytes in 0.148s)
Then I logged into android shell using ADB, You may use a Terminal Emulator software on the phone itself.
D:\>adb shell
I got root access and changed the file attributes of "count" binary to make it executable (same as on any Linux distribution). (You can either use chmod +x or chmod 777)
~ # su
root@android:/ # cd /system
root@android:/system # chmod 777 count
I executed "count" and tested ,
root@android:/system # ./count
./count
0
1
2
3
4
5
6
7
8
9
10
11|root@android:/system #
I also tested the program on phone using a terminal emulator too,
Comments