I cross-compiled the http Mongoose server for Android using Linux as BUILD system, android-ndk from Google as toolchain and a custom script that finally executes next command:
arm-linux-androideabi-gcc -DANDROID -march=armv7-a -mfpu=neon \
-mfloat-abi=softfp -mvectorize-with-neon-quad \
-I /opt/android-ndk-r9d/platforms/android-19/arch-arm/usr/include \
-I ~/Package_sources/BUILD_arm-linux-androideabi/include \
-DMONGOOSE_USE_LUA -DMONGOOSE_USE_LUA_SQLITE3 \
-L/opt/android-ndk-r9d/platforms/android-19/arch-arm/usr/lib \
-L~/Package_sources/BUILD_arm-linux-androideabi/lib \
-L~/Package_sources/BUILD_arm-linux-androideabi/lib -lluasqlite3 \
server.c mongoose.c -o server -llua51 -lm
The scripts works fine with no errors and a final 'server' elf executable is created. The problem I have now is when trying to launch it on Android. It complains that math symbols (defined in libm) like "floor" can not be found. I don't really understand why they can be found at compile time but not at run time, but I have some doubts about cross-compiling for Android and compilation setup that I describe next:
Some options/flags I chose to cross-compile are arbitrary since I do not fully understand all the (thousands of) gcc options and I chose what people suggest on different forums. In particular the -mfloat-abi=softfp, -mfpu=neon and -mvectorize-with-neon-quad
I also chose arbitrarily the platforms/android-19 since it was the newest installed in my system. I don't know exactly how different android-"N" versions differs and what are the implications of choosing one or another (is it safer to choose the newest one?, the oldest one?, or must I choose a different one for each different device/target?).
I also chose arbitrarily the gcc-4.6 arm-linux-androideabi-gcc build. There is also a gcc-4.8 installed in the android-ndk. Is there any preference, or again it depends on the final target? (or maybe it has nothing to do)
Thanks in advance for any help, hint or link!
Finally it looks the source of problems was a missing compilation flag in the LUA libraries (-DLUA_USE_DLOPEN). This caused the software to compile properly, but at runtime it failed to load so symbols defined "anywhere else".