11 Apr 2015 olea   » (Master)

Compiling node.js for Android Lollipop

While participating in the Nordic IoT Hackathon 2015 our team Hello North (wrongly tagged as «HackLab team») wanted to explore the potential of running node.js applications running native in Android.

Happily this was solved by Yaron Y. Goland and described in a post. Using his method I've compiled node.js against android-ndk-r10d running the example on a 4.2.2 rooted device.

The next step was to try in a unrooted one, but only got at first a 5.0 Lollipop one. Execution failed with a error: only position independent executables (PIE) are supported. error message. Some investigation got me to a solved bug report. The magic trick seems to be just this patch.

It took me some time to understand how to add this to the node.js building configuration system but seems got fixed just like this:

--- /home/olea/node/android-configure~  2015-04-11 02:46:04.063966802 +0200
+++ /home/olea/node/android-configure   2015-04-11 01:56:34.470154253 +0200
@@ -6,14 +6,16 @@
     --toolchain=arm-linux-androideabi-4.8 \
     --arch=arm \
     --install-dir=$TOOLCHAIN \
-    --platform=android-9
+    --platform=android-16
 export PATH=$TOOLCHAIN/bin:$PATH
 export AR=arm-linux-androideabi-ar
 export CC=arm-linux-androideabi-gcc
 export CXX=arm-linux-androideabi-g++
 export LINK=arm-linux-androideabi-g++
+export CPPFLAGS="-fPIE"
+export LDFLAGS="-fPIE -pie -L$PREFIX/lib"
 

And this is the test:

¡Yepa!

PS: Just checked the same build using android-16 platform runs in 4.2.2. ¡Double Yepa!

Syndicated 2015-04-11 06:20:00 from Ismael Olea

Latest blog entries     Older blog entries

New Advogato Features

New HTML Parser: The long-awaited libxml2 based HTML parser code is live. It needs further work but already handles most markup better than the original parser.

Keep up with the latest Advogato features by reading the Advogato status blog.

If you're a C programmer with some spare time, take a look at the mod_virgule project page and help us with one of the tasks on the ToDo list!