Nov 14

You have to love the hacker communities that come up around embedded devices. Although most of the talk around Android development has been Java, the platform is built on Linux, has an ARM chip, and thus you can compile some C!

Tom Cooksey was one of the first to get “Hello World” working in the emulator (and it is a true emulator, so if it works there, it will work on the devices):

1) Create your hello world program:

#include

int main(int argc, char** argv) {
printf(”hello world\n”);
return 0;

}

2) Compile with an arm cross-compiler toolchain. I used a toolchain I
built with gentoo’s crossdev tool, but there are lots out there.
Assuming your c file is hi.c and your cross compiler is called armv6-
vfp-linux-gnueabi-gcc, you can compile using:

armv6-vfp-linux-gnueabi-gcc hi.c -o hi -static

Note the -static. I’ve not figured out the version of libc etc or the
ABI used yet, so for now, link applications statically.

3) Copy to a running emulator:
adb push hi /system/sbin/hi

4) Run it! From the emulator console:
cd /system/sbin
./hi

5) Smile as you see “hello world” printed on the console. :-)

That being said, you are recommended to check out the TOS and think about the ease of using the nice Java APIs ;)