The SDL forums have moved to discourse.libsdl.org.
This is just a read-only archive of the previous forums, to keep old links working.


SDL Forum Index
SDL
Simple Directmedia Layer Forums
Static linking and dynamic OpenGL
Stephen Anthony
Guest

I'm not sure if this is SDL related, so if it isn't can someone please
direct me to the proper people.

I'm having a problem with static linking a binary and dynamically
loading OpenGL (using SDL_GL_LoadLibrary). When doing non-static
linking, dynamically loading the GL lib works fine. This has been
tested in Linux/OSX/Win32. But when I statically link the app in
Linux, switching to OpenGL mode just causes a segfault. It may not
have to do with the static linking at all, but that's the only time I
see it.

FYI, this is a GPL application (Stella, Atari 2600 emulator), so it's
freely available, and I'm not trying to bypass the GPL by doing a
static build. I'm just trying to set up nightly builds that are
independent of distro.

Anyone heard of this before?

Thanks,
Steve
Static linking and dynamic OpenGL
Sam Lantinga
Guest

Quote:
I'm not sure if this is SDL related, so if it isn't can someone please
direct me to the proper people.

Quote:
I'm having a problem with static linking a binary and dynamically
loading OpenGL (using SDL_GL_LoadLibrary). When doing non-static
linking, dynamically loading the GL lib works fine. This has been
tested in Linux/OSX/Win32. But when I statically link the app in
Linux, switching to OpenGL mode just causes a segfault. It may not
have to do with the static linking at all, but that's the only time I
see it.

I don't think you can statically link an application and dynamically load GL
under Linux. Ryan, have you ever done this?

-Sam Lantinga, Senior Software Engineer, Blizzard Entertainment
Static linking and dynamic OpenGL
Ryan C. Gordon
Guest

Quote:
I don't think you can statically link an application and dynamically load GL
under Linux. Ryan, have you ever done this?

Statically linking what? OpenGL, SDL, both? Are you using the -static
command line?

--ryan.
Static linking and dynamic OpenGL
Stephen Anthony
Guest

On January 19, 2006 06:21 am, Ryan C. Gordon wrote:
Quote:
Quote:
I don't think you can statically link an application and
dynamically load GL under Linux. Ryan, have you ever done this?

Statically linking what? OpenGL, SDL, both? Are you using the -static
command line?

Maybe I'm confusing the terms. Here's a clearer breakdown:

Case 1) App is statically linked, but isn't linked to OpenGL at all.
Doing 'ldd' results in 'static executable'. When using
SDL_GL_LoadLibrary(), it causes a segfault.

Case 2) App is using shared libs, and still isn't linked to OpenGL.
Doing 'ldd' lists all the libs linked to the app. Using
SDL_GL_LoadLibrary() in this case works fine.

So, overall:

1) OpenGL is *never* linked to the app at all, and is loaded through
SDL_GL_LoadLibrary().

2) Both cases work fine in OSX and Win32. So it seems the problem only
occurs when a static Linux binary attempts to dynamically load OpenGL
through SDL_GL_LoadLibrary().

3) The point of this whole exercise is to get around the brokenness of
Linux wrt creating an app that will work everywhere. Notice that OSX
and Win32 don't have a problem with that.

Steve
Static linking and dynamic OpenGL
Andreas Umbach
Guest

Quote:

3) The point of this whole exercise is to get around the brokenness of
Linux wrt creating an app that will work everywhere. Notice that OSX
and Win32 don't have a problem with that.


I dynamically link libc, pthread, X11 and OpenGL, and statically link
everything else. I've never had a problem with that. My magic LIBS line is:

LIBS = -L/usr/X11R6/lib -L/usr/local/lib -Wl,-rpath,/usr/local/lib,-Bstatic
-lSDL_sound -lSDL -lsmpeg -lmikmod -lvorbisfile -lvorbis -logg -lXxf86dga
-lXxf86vm -lXv -lXinerama -lXi -lpng -lz -lstdc++ -Wl,-Bdynamic -lpthread
-lGL -lX11 -lXext -ldl

- Andreas
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.libsdl.org/pipermail/sdl-libsdl.org/attachments/20060120/b8421183/attachment.html
Static linking and dynamic OpenGL
Stephen Anthony
Guest

On January 20, 2006 06:33 am, Andreas Umbach wrote:
Quote:
Quote:
3) The point of this whole exercise is to get around the
brokenness of Linux wrt creating an app that will work everywhere.
Notice that OSX and Win32 don't have a problem with that.

I dynamically link libc, pthread, X11 and OpenGL, and statically link
everything else. I've never had a problem with that. My magic LIBS
line is:

LIBS = -L/usr/X11R6/lib -L/usr/local/lib
-Wl,-rpath,/usr/local/lib,-Bstatic -lSDL_sound -lSDL -lsmpeg -lmikmod
-lvorbisfile -lvorbis -logg -lXxf86dga -lXxf86vm -lXv -lXinerama -lXi
-lpng -lz -lstdc++ -Wl,-Bdynamic -lpthread -lGL -lX11 -lXext -ldl

Thanks for that, I'll try it out.

Steve