Hi all,
(David, please take a look below)
I've sit down tonight and got gnustep-base to run under Android. The hardest part is having to manually load the dynamic libraries; apparently Android's android.app.NativeActivity is dumb enough to fail miserably when it has to (oh shock and horror) load a library that the .so containing native depends on.
(For those who don't know, Android applications cannot be written purely in native code. Even NativeActivity class, introduced relatively late and used primarily for games, is code written in Java that loads a shared object library and calls native code at appropriate times.)
Native code on Android in any non-console application is delivered as an .so. If it shows up on screen, it's not a standalone ELF executable. Simple as that. Hence the modus operandi is this: Application is always written in Java. Java code uses JNI to load an .so. Java code then calls C functions as appropriate. Native code may call back into Java.
-- Where was I stuck?
When it comes to usual GNU/Linux systems, libobjc2 is a good behaving citizen that specifies soname in the form of "libobjc.so.4.6"; when it comes to Android systems, libgnustep-base is a better behaving citizen that specifies so name in the form of "libgnustep-base.so". On regular systems, end user may not notice, as both are shipped as "libXYZ.so.A.B" and symlinked into "libXYZ.so". libobjc2 follows the recommendations, though, and libgnustep-base does not.
Doesn't really matter on Android, as the requirements are completely opposite; if you put a binary in "...apkroot/lib/armeabi" and it doesn't have the extension .so, it won't get shipped. Dynamic loader will choke when trying to load libgnustep-base.so which references to libobjc2 based on its soname; same for libAPPNAME.so.
David:
The hack that I found online, where I edit libgnustep-base.so and libAPPNAME.so to replace "libobjc.so.4.6" with "libobjc.so\0\0\0\0" is just that - a hack.
Can you look into the best way to force CMake to pass -soname libobjc.so to the linker, but just on Android? I have a CMake toolchain file for Android, but I'm unsure how to specify that the version number should not be suffixed on Android.
-- So, what does the .apk that I have do?
Nothing much:
NSString * hello = @"hello";
LOGI([hello UTF8String]);
which is just enough to see the output in Android's "logcat".