Blog

In my post about OpenMP on Android, I mentioned that your app will crash if you try to use OpenMP directives or functions on a non-main thread. That can be traced back to the gomp_thread function in libgomp/libgomp.h, and the fact that it returns NULL for threads you create.

Recently, I've had to build a custom Android NDK toolchain from source. The steps below detail my approach. I used a fresh install of Ubuntu 12.04 64-bit in a virtual machine with 6GB of RAM and a large amount of disk space, in conjuction with NDK r9.

After generating coverage data for your code, gcov can be used to create a report that shows the number of times each line is executed. lcov is a graphical front-end for gcov and can also be used. Personally, I much prefer lcov's HTML output, so that's what I'll use here.

On the Android platform, code coverage is available using Ant+Emma. However, that only covers Java code, so if your app is composed of native code as well, you'll want another tool. Fortunately, Gcov is one such tool, and is reasonably easy to setup.

In the hope that it might be useful for someone else out there, here are the steps that I use to build FreeImage for Android. These instructions were written for FreeImage 3.15.4 and NDK r8d. Using other versions of FreeImage or the NDK build system may require changes.