Static linking

I’m doing a project with SDL and this is the line I use with gcc for
static linking:

STATICLIBS = -static -L/usr/lib -lSDL -lpthread -lm -L/usr/X11R6/lib
-lX11 -lXext -ldl -L/usr/lib -lSDL_net -lSDL_ttf -lttf -lSDL_mixer -lesd
-laudiofile -lsmpeg -lvorbisfile -lvorbis -logg -lslang -lgpm -lncurses
-laa -lc

$(PROJECT): $(OBJ)
$(CXX) $(CXXFLAGS) -o $@ $(OBJ) $(STATICLIBS)

In my Debian Woody system I get the following link errors:
/usr/lib/libSDL_mixer.a(mixer.o): In function mix_channels': mixer.o(.text+0x2f1): undefined reference toSDL_MixAudio’
mixer.o(.text+0x387): undefined reference to SDL_MixAudio' /usr/lib/libSDL_mixer.a(mixer.o): In functionMix_LoadWAV_RW’:
mixer.o(.text+0x908): undefined reference to SDL_LoadWAV_RW' mixer.o(.text+0x994): undefined reference toSDL_FreeWAV’
mixer.o(.text+0x9ea): undefined reference to SDL_FreeWAV' mixer.o(.text+0xa09): undefined reference toSDL_FreeWAV’
/usr/lib/libSDL_mixer.a(music_ogg.o): In function OGG_playAudio': music_ogg.o(.text+0x330): undefined reference toSDL_MixAudio’
/usr/lib/libsmpeg.a(mpegtoraw.lo): In function Play_MPEGaudio(MPEGaudio *, unsigned char *, int)': mpegtoraw.lo(.text+0xac4): undefined reference toSDL_MixAudio’
mpegtoraw.lo(.text+0xb2d): undefined reference to `SDL_MixAudio’

which seems to be a problem with SDL_mixer

Anybody knows which libraries do i have to include and the order I have
to put them for gcc?

Thanks

Lorenzo Gil Sanchez

At 12:16 AM 5/28/02 -0700, you wrote:

I’m doing a project with SDL and this is the line I use with gcc for
static linking:

STATICLIBS = -static -L/usr/lib -lSDL -lpthread -lm -L/usr/X11R6/lib
-lX11 -lXext -ldl -L/usr/lib -lSDL_net -lSDL_ttf -lttf -lSDL_mixer -lesd
-laudiofile -lsmpeg -lvorbisfile -lvorbis -logg -lslang -lgpm -lncurses
-laa -lc
mpegtoraw.lo(.text+0xb2d): undefined reference to `SDL_MixAudio’
Anybody knows which libraries do i have to include and the order I have
to put them for gcc?

It’s the classic library dependency problem, you don’t get a symbol
imported if it’s needed only by a library that’s placed in the command line
after the library that exports that symbol.

Just place -lSDL AFTER all -lSDL_xxx libs in you STATICLIBS definition.

Bye,
Gabry (gabrielegreco at tin.it)

Hi
I do with Eclipse on Ubuntu:

Invoking: GCC C++ Linker
g++ -Wl,-Bstatic -lSDL -Wl,-Bdynamic,-rpath=. -shared -o “lin.xpl” ./main.o ./myList.o -lopenal -lcurl -lGL
Finished building target: lin.xpl

without -lSDL at the end I get sdl-quit not found or alike errors. How to link statically sdl and later sdl_ttf for a X-Plane plugin.
Thanks

This error:
dlerror:/media/michael/DATA/X-Plane_10/Aircraft/General Aviation/P4/plugins/p4/64/lin.xpl: undefined symbol: SDL_Quit