[Motorola Milestone Android Development] scholbert:
Hi geeks,

of course native ARM code compiling could be done with the full blown SDK+NDK, but honestly i found it way too much in some cases.

So i started investigating about a more simple cross environment.

There are many solutions out there, but IMHO the easiest way is to use the agcc wrapper written by Andrew Ross.

To make it comfortable, one of the prebuilt toolchains from the android source repository is used (gcc-4.4.0).

The environemnt will create dynamically linked executables, so we will link against the bionic libs here.

If you don't know what i'm talking about, follow the links at the bottom or step over to use your phone as a phone.

In fact this solution is not re-inventing the wheel, but more a walk on a practical trail for native development.

Everything could be easily put together and equipped with the essential source packages, you get a very handy solution to compile simple c-code for your Android platform.

Only minor tweaks had been done to the agcc wrapper, and you might do as well to fit it to your needs.

Grab the complete package here:

http://dl.dropbox.com/u/8815400/android-agcc-4.4.0.tar.gz

Everything was choosen to work nicely for the Milestone platform.

To make it the most compatible i decided to use the includes and libs from the eclair branches.

It might also work for other devices, but some tweaks could be required then.

To start development for your platform you'll need a more or less up-to-date linux OS on your host.

Minimum should be:

Debian 5.0

Ubuntu 10

...

Simply extract the archive to a directory of your choice, user rights should be O.K. (the default directory of the package would be /opt).

To make everything work properly, it is required to modify the $DROID variable insdide agcc wrapper to point at your working directory (e.g. /opt/android).

It is also required to add the path to the android toolchain to the PATH variable of your system. There are different attempts to do so.

E.g. on Debian 5.0 add the following line at the end of your .bashrc:

export PATH=$PATH:/opt/android/prebuilt/linux-x86/toolchain/arm-eabi-4.4.0/bin

To check, if the toolchain is working, create a simple hello.c like this:

#include <stdio.h>
main()
{
printf ("Hello World!\n");
}

Compile the code on your host:

./agcc hello.c -o hello

The result is a 32-bit ELF executable for ARM. Transfer the binary to your platform and make it executable.

You might use adb to do so (usb debugging needs to be activated on your device).

Attach the Milestone to your host and type:

./adb start-server

./adb push hello /data/local

./adb shell

Now in the shell on your device type:

$ cd /data/local

$ chmod +x hello

$ ./hello

There you go!

It is also possible to compile even more complex tools using MAKEFILE.

Some details might be discussed here, if there's some interest.

Useful links:

The essential packages had been taken from source packages over here:

http://android.git.kernel.org/

Also some libs had been grabbed from this project:

http://gitorious.org/rowboat

Original agcc wrapper could be found here:

http://plausible.org/andy/agcc

Further information:

http://labs.embinux.org/index.php/Toolchain_For_Android

http://android-dls.com/wiki/index.php?title=Compiling_for_Android

http://elinux.org/Android_Tools

Happy hacking!

scholbert