jarikomppa / soloud

Free, easy, portable audio engine for games
http://soloud-audio.com
Other
1.76k stars 275 forks source link

SDL2 backend: dlopen problems on Linux (not using SONAME with dlopen) #323

Open eliasdaler opened 3 years ago

eliasdaler commented 3 years ago

Hello I'm using soloud with SDL2 compiled as a shared library on Linux (Ubuntu 20.04 to be exact) When linking with SDL2 using its CMake, I get a link with libSDL2-2.0.so.0 which is a symlink to libSDL2-2.0.so.0.14.0

This causes dlopen in sdl2_openDll() function to fail, as it fails to find libSDL2.so or SDL2.so that it searches for. However, the fix is pretty simple (I can provide the PR if I got this right):

static void * sdl2_openDll()
{
    void * res;
    res = dlopen("/Library/Frameworks/SDL2.framework/SDL2", RTLD_LAZY);
    if (!res) res = dlopen("SDL2.so", RTLD_LAZY);
    if (!res) res = dlopen("libSDL2.so", RTLD_LAZY);
    if (!res) res = dlopen("libSDL2-2.0.so.0", RTLD_LAZY);  // <---- need to add this line
    return res;
}

Also please see this post from Ryan C. Gordon (one of the main devs of SDL) saying that "libSDL2-2.0.so.0" is the SONAME that should be used. Also see:

$ objdump -p third_party/sdl/libSDL2-2.0.so | grep SONAME
  SONAME               libSDL2-2.0.so.0
jarikomppa commented 2 years ago

PR would be nice, even for small things like this =)