[SDL] Re : statically linking

Mikael Eriksson mikael_eriksson at miffe.org
Thu Dec 2 10:11:16 PST 2010


On Thu, Dec 02, 2010 at 09:44:20AM +0000, azer tyuiop wrote:
> Well I tried, it made things advance. Now I get many undefined references to 
> other libs, like png, jpeg (exemple at the end) etc. 
> 
> I used the additional links that I found here : 
> http://stackoverflow.com/questions/115813/how-to-statically-compile-an-sdl-game-on-windows
> 
> 
> My LDFLAGS is no : 
> LDFLAGS      = -Wl,-Bstatic -lSDL_image `sdl-config --cflags --static-libs` 
> -Wl,-Bdynamic `directfb-config --libs` -lpng12 -ltiff -ljpeg -lasound -laudio 
> -lesd -lpulse-simple -lcaca -laa -ldl
>  
> Now, I have nearly only a problem with pulse audio. When I don't use the 
> -lpulse-simple lib I get errors like this :
> /usr/lib/libSDL.a(SDL_pulseaudio.o): In function `PULSE_CloseAudio':
> (.text+0x14e): undefined reference to `pa_simple_drain'

Seems like your distribution doen't provide you with a static version of
libpulse (it isn't built by default, which might be why). sdl-config
--static-libs list -lpulse-simple so it tries to link it staticly. You
can work around it with something like:

LDFLAGS      = -Wl,-Bstatic -lSDL_image -lSDL -Wl,-Bdynamic
`directfb-config --libs` -lpng12 -ltiff -ljpeg -lasound -laudio -lesd
-lpulse-simple -lcaca -laa -ldl -lm -lpthread

> 
> And when I add -lpulse, or -lpulse-simple, it do not find it.
> /usr/bin/ld: cannot find -lpulse-simple
> 
> But I checked and I do have libpulse ad libpulse-simple in /usr/lib. What can I 
> do?
> Thx for the help.
> 
> /usr/lib/libSDL_image.a(IMG_jpg.o): In function `IMG_InitJPG':
> (.text+0x12): undefined reference to `jpeg_calc_output_dimensions'
> /usr/lib/libSDL_image.a(IMG_jpg.o): In function `IMG_InitJPG':
> (.text+0x1c): undefined reference to `jpeg_CreateDecompress'
> /usr/lib/libSDL_image.a(IMG_jpg.o): In function `IMG_InitJPG':
> (.text+0x26): undefined reference to `jpeg_destroy_decompress'
> /usr/lib/libSDL_image.a(IMG_jpg.o): In function `IMG_InitJPG':
> (.text+0x30): undefined reference to `jpeg_finish_decompress'
> /usr/lib/libSDL_image.a(IMG_jpg.o): In function `IMG_InitJPG':
> (.text+0x3a): undefined reference to `jpeg_read_header'
> /usr/lib/libSDL_image.a(IMG_jpg.o): In function `IMG_InitJPG':
> (.text+0x44): undefined reference to `jpeg_read_scanlines'
> /usr/lib/libSDL_image.a(IMG_jpg.o): In function `IMG_InitJPG':
> (.text+0x4e): undefined reference to `jpeg_resync_to_restart'
> /usr/lib/libSDL_image.a(IMG_jpg.o): In function `IMG_InitJPG':

I have no idea why this happens, it should work since you link with
libjpeg.



More information about the SDL mailing list