Problem while linking SDL_mixer-1.2.0 statically

Hi,
I am using SDL-1.2.2, SDL_mixer-1.2.0 on RH6.2 platform. In my game I
want to link SDL as well as SDL_mixer statically but mixer gives me
’Undefined reference to …" error. Following is the part of my Makefile:

LIBST= -L/usr/local/lib -L/usr/local/lib -Wl,-rpath,/usr/local/lib -lSDL -lp
thread -lm -L/usr/X11R6/lib -lX11 -lXext -lXxf86vm -lXxf86dga
/usr/local/lib/libSDL_ttf.a
usr/local/lib/libfreetype.a -L/usr/local/SDL-1.2.2/test/SDL_mixer-1.2.0/.li
bs -L/usr/local/SDL-1.2.2/test/SDL_mixer-1.2.0/mikmod/.libs -L/usr/loacl/SDL
-1.2.2/test/SDL_mixer-1.2.0/timidity/.libs -L/usr/local/SDL-1.2.2/test/SDL_m
ixer-1.2.0 /usr/local/SDL-1.2.2/test/SDL_mixer-1.2.0/.libs/libSDL_mixer.a

I tried many ways of linking the mixer statically ie remove all '.so'

files from /usr/local/lib folder. In this Makefile I am explicitly trying to
link ‘.a’ file of SDL_mixer. I even tried SDL_mixer-1.2.1. I get following
error:

/usr/local/SDL-1.2.2/test/SDL_mixer-1.2.0/.libs/libSDL_mixer.a(mixer.o): In
function mix_channels': /usr/local/SDL-1.2.2/test/SDL_mixer-1.2.0/mixer.c:119: undefined reference toSDL_MixAudio’
/usr/local/SDL-1.2.2/test/SDL_mixer-1.2.0/mixer.c:130: undefined reference
to SDL_MixAudio' /usr/local/SDL-1.2.2/test/SDL_mixer-1.2.0/.libs/libSDL_mixer.a(mixer.o): In functionMix_LoadWAV_RW’:
/usr/local/SDL-1.2.2/test/SDL_mixer-1.2.0/mixer.c:301: undefined reference
to SDL_LoadWAV_RW' /usr/local/SDL-1.2.2/test/SDL_mixer-1.2.0/mixer.c:315: undefined reference toSDL_FreeWAV’
/usr/local/SDL-1.2.2/test/SDL_mixer-1.2.0/mixer.c:324: undefined reference
to SDL_FreeWAV' /usr/local/SDL-1.2.2/test/SDL_mixer-1.2.0/mixer.c:329: undefined reference toSDL_FreeWAV’

If I use the '.so' file (ie link SDL_mixer dynamically) I do not get any

errors. I also noticed one thing that one cannot compile SDL_mixer only
statically (ie generate only SDL_mixer.a file) if there is no ‘.so’ file of
SDL (ie libSDL.so…) file in the /usr/local/lib directory.
Am I doing anything wrong? I want to link all the SDL libraries statically.

regards,
Paresh.

You might want to link statically via the gcc command line option
"-static" :slight_smile:

Paresh wrote:> Hi,

I am using SDL-1.2.2, SDL_mixer-1.2.0 on RH6.2 platform. In my game I

want to link SDL as well as SDL_mixer statically but mixer gives me
’Undefined reference to …" error. Following is the part of my Makefile:

LIBST= -L/usr/local/lib -L/usr/local/lib -Wl,-rpath,/usr/local/lib -lSDL -lp
thread -lm -L/usr/X11R6/lib -lX11 -lXext -lXxf86vm -lXxf86dga
/usr/local/lib/libSDL_ttf.a
usr/local/lib/libfreetype.a -L/usr/local/SDL-1.2.2/test/SDL_mixer-1.2.0/.li
bs -L/usr/local/SDL-1.2.2/test/SDL_mixer-1.2.0/mikmod/.libs -L/usr/loacl/SDL
-1.2.2/test/SDL_mixer-1.2.0/timidity/.libs -L/usr/local/SDL-1.2.2/test/SDL_m
ixer-1.2.0 /usr/local/SDL-1.2.2/test/SDL_mixer-1.2.0/.libs/libSDL_mixer.a

I tried many ways of linking the mixer statically ie remove all '.so'

files from /usr/local/lib folder. In this Makefile I am explicitly trying to
link ‘.a’ file of SDL_mixer. I even tried SDL_mixer-1.2.1. I get following
error:

/usr/local/SDL-1.2.2/test/SDL_mixer-1.2.0/.libs/libSDL_mixer.a(mixer.o): In
function mix_channels': /usr/local/SDL-1.2.2/test/SDL_mixer-1.2.0/mixer.c:119: undefined reference toSDL_MixAudio’
/usr/local/SDL-1.2.2/test/SDL_mixer-1.2.0/mixer.c:130: undefined reference
to SDL_MixAudio' /usr/local/SDL-1.2.2/test/SDL_mixer-1.2.0/.libs/libSDL_mixer.a(mixer.o): In functionMix_LoadWAV_RW’:
/usr/local/SDL-1.2.2/test/SDL_mixer-1.2.0/mixer.c:301: undefined reference
to SDL_LoadWAV_RW' /usr/local/SDL-1.2.2/test/SDL_mixer-1.2.0/mixer.c:315: undefined reference toSDL_FreeWAV’
/usr/local/SDL-1.2.2/test/SDL_mixer-1.2.0/mixer.c:324: undefined reference
to SDL_FreeWAV' /usr/local/SDL-1.2.2/test/SDL_mixer-1.2.0/mixer.c:329: undefined reference toSDL_FreeWAV’

If I use the '.so' file (ie link SDL_mixer dynamically) I do not get any

errors. I also noticed one thing that one cannot compile SDL_mixer only
statically (ie generate only SDL_mixer.a file) if there is no ‘.so’ file of
SDL (ie libSDL.so…) file in the /usr/local/lib directory.
Am I doing anything wrong? I want to link all the SDL libraries statically.

regards,
Paresh.


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl

“Paresh” == Paresh writes:

[…]

Paresh> I tried many ways of linking the mixer statically ie
Paresh> remove all ‘.so’ files from /usr/local/lib folder. In
Paresh> this Makefile I am explicitly trying to link ‘.a’ file
Paresh> of SDL_mixer. I even tried SDL_mixer-1.2.1. I get
Paresh> following error:

Paresh> /usr/local/SDL-1.2.2/test/SDL_mixer-1.2.0/.libs/libSDL_mixer.a(mixer.o):
Paresh> In function mix_channels': Paresh> /usr/local/SDL-1.2.2/test/SDL_mixer-1.2.0/mixer.c:119: Paresh> undefined reference toSDL_MixAudio’

Because SDL_mixer depends upon SDL, -lSDL should appears
after -lSDL_mixer in your link arguments (just think that you
use a library to supply symbols required by previous objects).

[…]–
Alexandre Duret-Lutz

“Paresh” == Paresh writes:

[…]

Paresh> If I use the ‘.so’ file (ie link SDL_mixer dynamically)
Paresh> I do not get any errors. I also noticed one thing that
Paresh> one cannot compile SDL_mixer only statically (ie
Paresh> generate only SDL_mixer.a file) if there is no '.so’
Paresh> file of SDL (ie libSDL.so…) file in the
Paresh> /usr/local/lib directory. Am I doing anything wrong? I
Paresh> want to link all the SDL libraries statically.

I do this everytime I cross-compile SDL for MinGW: just
configure both libraries with --disable-shared --enable-static.–
Alexandre Duret-Lutz

It worked after adding -lSDL. Thanks a lot.

regards,
Paresh.> Message: 24

To: sdl at libsdl.org
Subject: Re: [SDL] Problem while linking SDL_mixer-1.2.0 statically
From: Alexandre Duret-Lutz <duret_g at lrde.epita.fr>
Date: Thu, 21 Feb 2002 17:46:08 +0100
Reply-To: sdl at libsdl.org

“Paresh” == Paresh <@Paresh> writes:

[…]

Paresh> I tried many ways of linking the mixer statically ie
Paresh> remove all ‘.so’ files from /usr/local/lib folder. In
Paresh> this Makefile I am explicitly trying to link ‘.a’ file
Paresh> of SDL_mixer. I even tried SDL_mixer-1.2.1. I get
Paresh> following error:

Paresh>
/usr/local/SDL-1.2.2/test/SDL_mixer-1.2.0/.libs/libSDL_mixer.a(mixer.o):
Paresh> In function mix_channels': Paresh> /usr/local/SDL-1.2.2/test/SDL_mixer-1.2.0/mixer.c:119: Paresh> undefined reference toSDL_MixAudio’

Because SDL_mixer depends upon SDL, -lSDL should appears
after -lSDL_mixer in your link arguments (just think that you
use a library to supply symbols required by previous objects).

[…]


Alexandre Duret-Lutz