[Commits] SDL: Fixed bug 2812 - Make libSDL2main.a usable on Android via a...

libsdl.org revision control commits-owner at libsdl.org
Sun Aug 13 18:12:09 PDT 2017


details:   https://hg.libsdl.org/SDL/rev/f85618f8ba81
changeset: 11263:f85618f8ba81
user:      Sam Lantinga <slouken at libsdl.org>
date:      Sun Aug 13 18:12:06 2017 -0700
description:
Fixed bug 2812 - Make libSDL2main.a usable on Android via a dummy symbol

Jonas Kulla

This eliminates the need to manually compile in SDL_main_android.c.
Instead, add "-lSDL2main -Wl,-u,SDL_main_dummy" when linking.

I don't know how the nkd-build process works, but unless it was
for some reason linking libSDL2main.a it should be unaffected.

diffstat:

 configure                           |  2 ++
 configure.in                        |  2 ++
 src/main/android/SDL_android_main.c |  3 +++
 3 files changed, 7 insertions(+), 0 deletions(-)

diffs (41 lines):

diff -r 8e5441ab6c63 -r f85618f8ba81 configure
--- a/configure	Sun Aug 13 17:59:59 2017 -0700
+++ b/configure	Sun Aug 13 18:12:06 2017 -0700
@@ -23555,8 +23555,10 @@
                 ANDROID_CFLAGS="-DGL_GLEXT_PROTOTYPES"
                 CFLAGS="$CFLAGS $ANDROID_CFLAGS"
                 SDL_CFLAGS="$SDL_CFLAGS $ANDROID_CFLAGS"
+                SDL_LIBS="$SDL_LIBS -lSDL2main -Wl,-u,SDL_main_dummy"
                 EXTRA_CFLAGS="$EXTRA_CFLAGS $ANDROID_CFLAGS"
                 EXTRA_LDFLAGS="$EXTRA_LDFLAGS -ldl -lGLESv1_CM -lGLESv2 -llog -landroid"
+                SDLMAIN_SOURCES="$srcdir/src/main/android/*.c"
 
                 if test x$enable_video = xyes; then
                     SOURCES="$SOURCES $srcdir/src/core/android/*.c $srcdir/src/video/android/*.c"
diff -r 8e5441ab6c63 -r f85618f8ba81 configure.in
--- a/configure.in	Sun Aug 13 17:59:59 2017 -0700
+++ b/configure.in	Sun Aug 13 18:12:06 2017 -0700
@@ -3160,8 +3160,10 @@
                 ANDROID_CFLAGS="-DGL_GLEXT_PROTOTYPES"
                 CFLAGS="$CFLAGS $ANDROID_CFLAGS"
                 SDL_CFLAGS="$SDL_CFLAGS $ANDROID_CFLAGS"
+                SDL_LIBS="$SDL_LIBS -lSDL2main -Wl,-u,SDL_main_dummy"
                 EXTRA_CFLAGS="$EXTRA_CFLAGS $ANDROID_CFLAGS"
                 EXTRA_LDFLAGS="$EXTRA_LDFLAGS -ldl -lGLESv1_CM -lGLESv2 -llog -landroid"
+                SDLMAIN_SOURCES="$srcdir/src/main/android/*.c"
 
                 if test x$enable_video = xyes; then
                     SOURCES="$SOURCES $srcdir/src/core/android/*.c $srcdir/src/video/android/*.c"
diff -r 8e5441ab6c63 -r f85618f8ba81 src/main/android/SDL_android_main.c
--- a/src/main/android/SDL_android_main.c	Sun Aug 13 17:59:59 2017 -0700
+++ b/src/main/android/SDL_android_main.c	Sun Aug 13 18:12:06 2017 -0700
@@ -15,6 +15,9 @@
 *******************************************************************************/
 #include <jni.h>
 
+/* Dummy symbol so '-u SDL_main_dummy' forces ld to link in libSDL2main.a */
+JNIEXPORT int SDL_main_dummy;
+
 /* Called before SDL_main() to initialize JNI bindings in SDL library */
 extern void SDL_Android_Init(JNIEnv* env, jclass cls);
 


More information about the commits mailing list