Thursday, February 23, 2012

Building Your Favorite Glibc App for Android

There are a lot of great applications built on glibc that embedded Linux developers have made the mainstay of building embedded Linux systems. Among these are busybox, wget, cron, thttpd, and many others. The question is, can you get these to run under Android?

The answer is yes! (and no). Technically it would be a LOT of work to port these to use bionic, the c library that Android uses. However, nothing in Android restricts you from adding a standard glibc to your distribution and then using it with the standard programs.

Karihm did a great presentation on this at the Android Builders Summit. He showed an example of building busybox and adding glibc to the system. You can download his slides here: (a video of the presentation will be coming soon.)

Another option is to statically compile your binaries with the libraries that they would normally find on a glibc based system. The problem with statically compiling is that it pulls in all the code from the libraries that the code needs directly into the binary. If you have more than one program you are going to do this to, however, you would be better off building against the library. Busybox, which is usually just a few hundred K ends up being 2 MB if it's statically linked.

As the post about Ubuntu on Android shows, this is a great way to have your cake and eat it too.

No comments:

Post a Comment