We are currently migrating Bugzilla to GitHub issues.
Any changes made to the bug tracker now will be lost, so please do not post new bugs or make changes to them.
When we're done, all bug URLs will redirect to their equivalent location on the new bug tracker.

Bug 1828

Summary: static linking breaks with applications that use X11
Product: SDL Reporter: nfxjfg
Component: *don't know*Assignee: Ryan C. Gordon <icculus>
Status: RESOLVED INVALID QA Contact: Sam Lantinga <slouken>
Severity: normal    
Priority: P2 CC: gabomdq
Version: HG 2.0   
Hardware: x86   
OS: Linux   

Description nfxjfg 2013-05-01 09:18:53 UTC
It appears SDL2 uses dlopen() to access Xlib, and uses the Xlib API function names for the stubs that call the loaded function pointers. This clashes with actual X11 function calls in applications, and will lead to crashes with applications that use both X11 and SDL2. (Consider mplayer, although mplayer proper uses SDL1.2, not sure if that has the same problem.) The first call to a X11 function will crash it, because the application code gets the SDL symbol instead of the libX11 symbol.

Of course this doesn't happen with dynamic linking, because the SDL .so doesn't export these X stubs.
Comment 1 Gabriel Jacobo 2013-05-02 22:51:15 UTC
Did you try using ./configure --disable-x11-shared ?
Comment 2 nfxjfg 2013-05-03 16:40:47 UTC
With "--disable-shared  --disable-x11-shared" I get undefined X symbols in SDL when linking the final application binary:

build_libs/lib/libSDL2.a(SDL_x11mouse.o): In function `X11_CreateXCursorCursor':
SDL/./src/video/x11/SDL_x11mouse.c:97: undefined reference to `XcursorImageCreate'
SDL/./src/video/x11/SDL_x11mouse.c:110: undefined reference to `XcursorImageLoadCursor'
SDL/./src/video/x11/SDL_x11mouse.c:112: undefined reference to `XcursorImageDestroy'
collect2: error: ld returned 1 exit status

(useless path prefixes cut)

With "--disable-x11-shared" it creates a .so.
Comment 3 Gabriel Jacobo 2013-05-03 16:50:22 UTC
You should add "-lXcursor" to your link line (and have libXcursor.so installed).

sdl2-config should probably be modified to add these X11 libraries if you specify --disable-x11-shared.
Comment 4 Gabriel Jacobo 2013-05-10 15:30:21 UTC
sdl2-config has the right flags required for static linking after all, marking as invalid.