Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to compile and run a C/C++ program on the Android system

Q1) I want to run a simple c program on android emulator.I am using windows xp os on my machine. I have installed sdk, jdk, eclipse for android development and succeeded running android application on AVD.

Q2) I just need to know is there any way to run a C program(without any java) on AVD. On my machine I have installed arm and using that I have compiled a C program.

Q3) I also want to know is it possible to push the compiled binary into android device or AVD and run using the terminal of the android device or AVD?

like image 481
user1125898 Avatar asked Jan 02 '12 08:01

user1125898


People also ask

Can I compile C on Android?

If you want to compile and run Java/C/C++ apps directly on your Android device, I recommend the Terminal IDE environment from Google Play. It's a very slick package to develop and compile Android APKs, Java, C and C++ directly on your device. The interface is all command line and "vi" based, so it has real Linux feel.


1 Answers

You can compile your C programs with an ARM cross-compiler:

arm-linux-gnueabi-gcc -static -march=armv7-a test.c -o test 

Then you can push your compiled binary file to somewhere (don't push it in to the SD card):

adb push test /data/local/tmp/test 
like image 113
Ashkan Avatar answered Oct 04 '22 19:10

Ashkan