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
Does anyone static link SDL2 ?
bilsch01


Joined: 26 Feb 2015
Posts: 55
Location: Seattle, WA, USA
I use Ubuntu OS. I am trying to static link my program (called graf.cpp) with the libraries required for SDL2. I have the sdl2-config file from a fresh SDL2 build.
When I run command line: sdl2-config --libs it tells me the libraries to link are: -L/usr/lib/x86_64-linux-gnu -lSDL2. -L/usr/lib/x86_64-linux-gnu references all of the libraries at that path, and -lSDL2 references SDL2 dynamic object specifically. Since i need to static link the libraries I run the following command line:
g++ graf.cpp -o graf --static -L/usr/lib/x86_64-linux-gnu -lSDL2. I am pretty sure this is the correct way to do it. When I do it, g++ generates hundreds of errors for undefined references and the build fails. I get a similar result when I link with only the flag -lSDL2. NOTE: I get similar result linking to all the *.a static library files for SDL2.

The problem is that the linked libraries contain references to things in other libraries not being linked. I need to link additional libraries. One indication of the missing libraries can be gotten running:
ldd /usr/lib/x86_64-linux-gnu/libSDL2-2.0.so.0.2.0 which shows 41 other libraries the that the dynamic library is dependent on. I assume the static libraries similarly require additional libraries. But these are unknown.

MY QUESTION is: has anyone here done static linking of SDL2 libraries? If so, please tell me how to do it
Does anyone static link SDL2 ?
neoaggelos


Joined: 02 Jan 2013
Posts: 138
There should be a --static-libs option for sdl2-config, containing the required libraries. On May 14, 2015 7:55 AM, "bilsch01" wrote:
Quote:
I use Ubuntu OS. I am trying to static link my program (called graf.cpp) with the libraries required for SDL2. I have the sdl2-config file from a fresh SDL2 build.
When I run command line: sdl2-config --libs it tells me the libraries to link are: -L/usr/lib/x86_64-linux-gnu -lSDL2. -L/usr/lib/x86_64-linux-gnu references all of the libraries at that path, and -lSDL2 references SDL2 dynamic object specifically. Since i need to static link the libraries I run the following command line:
g++ graf.cpp -o graf --static -L/usr/lib/x86_64-linux-gnu -lSDL2. I am pretty sure this is the correct way to do it. When I do it, g++ generates hundreds of errors for undefined references and the build fails. I get a similar result when I link with only the flag -lSDL2. NOTE: I get similar result linking to all the *.a static library files for SDL2.

The problem is that the linked libraries contain references to things in other libraries not being linked. I need to link additional libraries. One indication of the missing libraries can be gotten running:
ldd /usr/lib/x86_64-linux-gnu/libSDL2-2.0.so.0.2.0 which shows 41 other libraries the that the dynamic library is dependent on. I assume the static libraries similarly require additional libraries. But these are unknown.

MY QUESTION is: has anyone here done static linking of SDL2 libraries? If so, please tell me how to do it


_______________________________________________
SDL mailing list

http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

bilsch01


Joined: 26 Feb 2015
Posts: 55
Location: Seattle, WA, USA
Right. I tried that also (weeks ago). Using --static-libs with sdl2-config gives more linker flags but the following two error messages occur when using those flags:

warning: Using 'dlopen' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking.
/usr/bin/ld: cannot find -lts

I tried linking without flag -lts. It compiles but the resulting program hangs up. Which brings me back to my question: has anybody ever static linked with SDL2 ? If so, please tell me how.

Thanks. Bill S.
Dominus


Joined: 13 Oct 2009
Posts: 127
I'm static linking on OS X but that needed some tweaking of sdl2-config https://forums.libsdl.org/viewtopic.php?t=10956&highlight=
Does anyone static link SDL2 ?
Bob Rubbens
Guest

FWIW, I only managed to link statically by passing -static to the (that's one dash! I think...) to the *linker*. If I just passed it as a regular option it wouldn't work. I also didn't manage to only static link sdl, and everything else dynamically. For me it's either static everything or dynamic everything. Not sure why I couldn't get it to work but I suspect my lack of expertise.

On 14 May 2015 at 12:33, bilsch01 wrote:
Quote:
Right. I tried that also (weeks ago). Using --static-libs with sdl2-config gives more linker flags but the following two error messages occur when using those flags:

warning: Using 'dlopen' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking.
/usr/bin/ld: cannot find -lts

I tried linking without flag -lts. It compiles but the resulting program hangs up. Which brings me back to my question: has anybody ever static linked with SDL2 ? If so, please tell me how.

Thanks. Bill S.


_______________________________________________
SDL mailing list

http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org