Android: cannot locate symbol "SDL_Quit_REAL" referenced by "libSDL2.so"

I am getting the following error when trying to use SDL2 on Android:

java.lang.UnsatisfiedLinkError: dlopen failed: cannot locate symbol
"SDL_Quit_REAL" referenced by “libSDL2.so

This is with SDL hg 8664:565698ab1c40. This error did not occur with SDL
2.0.1 - my best guess is that it has something to do with the new dynapi
implementation.

I am building SDL using the following script:

./autogen.sh
./configure --host=arm-linux-androideabi --target=arm-linux-androideabi
./make -j
rm build/SDL_test*
$CC src/main/android/SDL_android_main.c -c -o build/SDL_main.o -Iinclude
$CC -shared build/*.o -o libSDL2.so

i.e. I am folding nativeInit() and SDL_main() into libSDL2.so, because I am
not actually using the C main() as the entry point to my application. (C
code does not have access to my entry point.)

My SDLActivity.java is identical to hg 8664:565698ab1c40, with a single
modification: the SDLMain thread does not exit as soon as SDL_main()
returns, but calls my real entry point instead. While unorthodox, this
works well enough with SDL 2.0.1, so I don’t believe the problem lies there.

Questions:

  1. Is it possible to turn off dynapi using the configure script?
  2. Alternatively, is there a way to export the necessary SDL_*_REAL symbols
    from libSDL2.so?
  3. Is there a practical difference between ndk-build and (autogen &&
    configure && make)? Could it make a difference in this case?
  4. Is there a better way to achieve what I am trying?

Your input would be appreciated!

2014-03-25 9:55 GMT-03:00 Stefanos A. :

I am getting the following error when trying to use SDL2 on Android:

java.lang.UnsatisfiedLinkError: dlopen failed: cannot locate symbol
"SDL_Quit_REAL" referenced by “libSDL2.so

In my experience these errors do occur by not including SDL_internal.h
where required…do you have a merge error perhaps?

Questions:

  1. Is it possible to turn off dynapi using the configure script?

I don’t think so. You’ll find that SDL_dynapi.h is specifically protected
against this…I actually think disabling it via the configure script may
be a good idea, but right now it’s designed so that’s not possible.

  1. Alternatively, is there a way to export the necessary SDL_*_REAL
    symbols from libSDL2.so?
  2. Is there a practical difference between ndk-build and (autogen &&
    configure && make)? Could it make a difference in this case?
  3. Is there a better way to achieve what I am trying?

If you have the right headers in place this should work automagically. The
dynapi stuff on Android is not very useful, because right now every app has
to ship SDL2, but it should work anyway (you can use the androidbuild.sh
script and SDL’s tests to confirm as much).–
Gabriel.

Be sure to use the latest build from the active repository. I think there
was resolved issue with the stuff you’re talking about

I updated to hg tip with no change. However, I noticed two things:

  1. SDL_dynapi.o is built correctly under the build/ directory (167KB).
    Running “arm-linux-androideabi-nm -g SDL_dynapi.o” indicates that both
    "SDL_quit" and “SDL_quit_REAL” exist in SDL_dynapi.o

  2. Running “arm-linux-androideabi-nm -g libSDL2.so” indicates that only
    SDL_quit is available in libSDL2.so - SDL_quit_REAL has somehow gone
    missing! Indeed, only a few SDL_*_REAL symbols exist in the shared object,
    most of them are missing.

I am using the following command to link the .o files into a shared library:

arm-linux-androideabi-gcc -shared build/*.o -o libSDL2.so

Does anyone see anything obviously wrong with this? Why would this command
skip some public symbols but not others?

Conversely, what is the correct way to build a shared libSDL2.so for
android? configure && make only creates a static library, which is why I am
linking the .o files manually.

2014-03-25 14:34 GMT+01:00 R Manard :> Be sure to use the latest build from the active repository. I think there

was resolved issue with the stuff you’re talking about


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

As an update, adding SDL_android_main.c to Android.mk and using ndk-build
produces a working libSDL2.so.

I’m still curious why configure && make is no longer working (it used to
work on SDL 2.0.1.)

2014-03-25 17:18 GMT+01:00 Stefanos A. <@Stefanos_A>:> I updated to hg tip with no change. However, I noticed two things:

  1. SDL_dynapi.o is built correctly under the build/ directory (167KB).
    Running “arm-linux-androideabi-nm -g SDL_dynapi.o” indicates that both
    "SDL_quit" and “SDL_quit_REAL” exist in SDL_dynapi.o

  2. Running “arm-linux-androideabi-nm -g libSDL2.so” indicates that only
    SDL_quit is available in libSDL2.so - SDL_quit_REAL has somehow gone
    missing! Indeed, only a few SDL_*_REAL symbols exist in the shared object,
    most of them are missing.

I am using the following command to link the .o files into a shared
library:

arm-linux-androideabi-gcc -shared build/*.o -o libSDL2.so

Does anyone see anything obviously wrong with this? Why would this command
skip some public symbols but not others?

Conversely, what is the correct way to build a shared libSDL2.so for
android? configure && make only creates a static library, which is why I am
linking the .o files manually.

2014-03-25 14:34 GMT+01:00 R Manard :

Be sure to use the latest build from the active repository. I think there
was resolved issue with the stuff you’re talking about


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

Does anyone see anything obviously wrong with this? Why would this
command skip some public symbols but not others?

The *_REAL symbols are not public; they should only be visible to SDL
itself.

–ryan.