I am trying to statically compile a program and I get a bunch of undefined
references. Can someone tell me what I am doing wrong?
Here is my compile line:
tojabr at linux:~/fail> gcc -static sdl-config --static-libs --cflags
-lSDL_mixer sound.c
/tmp/ccUdc9MY.o(.text+0x16): In function main': : undefined reference to
SDL_Init’
/tmp/ccUdc9MY.o(.text+0x2f): In function main': : undefined reference to
Mix_OpenAudio’
/tmp/ccUdc9MY.o(.text+0x37): In function main': : undefined reference to
SDL_Quit’
collect2: ld returned 1 exit status
Before anyone asks I do have the static libraries installed:
tojabr at linux:~/fail> ls /usr/lib/libSDL*.a
/usr/lib/libSDL.a /usr/lib/libSDLmain.a /usr/lib/libSDLmm.a
/usr/lib/libSDL_sound.a
/usr/lib/libSDL_image.a /usr/lib/libSDL_mixer.a /usr/lib/libSDL_net.a
/usr/lib/libSDL_ttf.a
here is the just the basic code I can’t get to compile statically:
#include “SDL.h”
#include “SDL_mixer.h”
int main()
{
SDL_Init(SDL_INIT_AUDIO);
Mix_OpenAudio(22050, AUDIO_S16SYS, 2, 2048);
SDL_Quit();
}
What am I doing wrong?
Tom
Tom Bradley wrote:
I am trying to statically compile a program and I get a bunch of undefined
references. Can someone tell me what I am doing wrong?
Here is my compile line:
tojabr at linux:~/fail> gcc -static sdl-config --static-libs --cflags
-lSDL_mixer sound.c
The problem is that there is no sdl-config for sdl_mixer, this is how
I’ve been able to compile your example manually, is not very clean, I’ve
had to solve also some circular dependency
[gabry at nevada tmp]$ gcc -o sound sound.c /usr/lib/libSDL_mixer.a
/usr/lib/libvorbisfile.a /usr/lib/libogg.a /usr/lib/libvorbis.a
/usr/lib/libogg.a /usr/lib/libSDL.a -L/usr/X11R6/lib -ldl -lX11 -lXext
-lpthread -lm sdl-config --cflags
[gabry at nevada tmp]$ ldd sound
libdl.so.2 => /lib/libdl.so.2 (0x40026000)
libX11.so.6 => /usr/X11R6/lib/libX11.so.6 (0x4002a000)
libXext.so.6 => /usr/X11R6/lib/libXext.so.6 (0x40108000)
libpthread.so.0 => /lib/i686/libpthread.so.0 (0x40116000)
libm.so.6 => /lib/i686/libm.so.6 (0x40166000)
libc.so.6 => /lib/i686/libc.so.6 (0x42000000)
/lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x40000000)
Bye,
Gabry
I was hoping for a cleaner way, this is the same path I was heading towards
when I decided to see if there was a cleaner way. Now I need to do the same
for SDL_ttf and SDL_image.
TomOn Tuesday 09 March 2004 2:31 am, Gabriele Greco wrote:
Tom Bradley wrote:
I am trying to statically compile a program and I get a bunch of
undefined references. Can someone tell me what I am doing wrong?
Here is my compile line:
tojabr at linux:~/fail> gcc -static sdl-config --static-libs --cflags
-lSDL_mixer sound.c
The problem is that there is no sdl-config for sdl_mixer, this is how
I’ve been able to compile your example manually, is not very clean, I’ve
had to solve also some circular dependency
[gabry at nevada tmp]$ gcc -o sound sound.c /usr/lib/libSDL_mixer.a
/usr/lib/libvorbisfile.a /usr/lib/libogg.a /usr/lib/libvorbis.a
/usr/lib/libogg.a /usr/lib/libSDL.a -L/usr/X11R6/lib -ldl -lX11 -lXext
-lpthread -lm sdl-config --cflags
[gabry at nevada tmp]$ ldd sound
libdl.so.2 => /lib/libdl.so.2 (0x40026000)
libX11.so.6 => /usr/X11R6/lib/libX11.so.6 (0x4002a000)
libXext.so.6 => /usr/X11R6/lib/libXext.so.6 (0x40108000)
libpthread.so.0 => /lib/i686/libpthread.so.0 (0x40116000)
libm.so.6 => /lib/i686/libm.so.6 (0x40166000)
libc.so.6 => /lib/i686/libc.so.6 (0x42000000)
/lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x40000000)
Bye,
Gabry
SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl