Embedding Perl on Android
The choice of using Perl in an Android project may not seem like an obvious one, indeed its not one that I would often recommend. However, with one of the largest repositories of free code in the world available through CPAN, the Comprehensive Perl Archive Network, the choice can come down to leveraging an off-the-shelf project. The one that got me interested was ExifTool by Phil Harvey that is by far the most powerful EXIF reader and writer out there. Why re-invent the wheel?
The Scripting Layer for Android (SL4A) project attempts to make, amongst other things, Perl scripts executable on Android. With little support Perl no longer functions on modern devices so I set out to see how I could make Perl executable myself.
With Perl 5.20 cross compiling for Android works out of the box, sort of. The one caveat is it doesn’t currently generate a position independent executable (PIE) which is needed to run on Android 5.0. PIE support was added in Android 4.1.
These instructions are based on David Farrells’ Perl Tricks article for compilation.
Compiling Perl for ARM
Follow these instructions to compile Perl for ARM. There are footnotes below to compile for x86 and MIPS.
- Download and install the Android NDK.
- Download the Perl source code. I successfully compiled version 5.22.1.
- Setup an ARM based emulator. The configure step compiles and executes some code using this to verify its…