Summary: configure fails to detect SDL_mixer
Submitted by: kernigh
Submitted on: Thursday 11/12/2009 at 21:15
Severity: 2 - Minor
Priority: 5 - Normal
Assigned to: None
Discussion Lock: Any
Operating System: *BSD
Planned Release: None
When I build freeciv-2.1.9 from source, the configure script fails to detect
SDL_mixer, so civclient has no sound. I build the GTK+ 2 client. My operating
system is OpenBSD.
My configure arguments were --prefix=/home/kernigh/prefix
The detection fails because the AC_CHECK_LIB in m4/sound.m4 forgets to use
SDL_LIBS (the output of sdl-config --libs) when checking SDL_mixer. For my
OpenBSD system, sdl-config --libs provides some extra flags that are always
necessary when linking to SDL, or to any library that requires SDL.
$ sdl-config --cflags
-I/usr/local/include -I/usr/local/include/SDL -D_GNU_SOURCE=1 -D_REENTRANT
$ sdl-config --libs
-L/usr/local/lib -lSDL -pthread -L/usr/X11R6/lib -R/usr/X11R6/lib
(OpenBSD system gcc is not searching /usr/local by default. OpenBSD has X11R7
So I modified m4/sound.m4 to use SDL_CFLAGS and SDL_LIBS when checking
SDL_mixer (similar to how m4/sdl-client.m4 uses SDL_CFLAGS and SDL_LIBS when
checking SDL_image). I have attached a patch.
I also changed the header check in m4/sound.m4. The check is for
'SDL_mixer.h' and *not* 'SDL/SDL_mixer.h', because 'SDL_mixer.h' is the
correct way to include the file (and because client/audio_sdl.c includes
After I modified m4/sound.m4, I ran 'aclocal -I m4' and 'autoconf' to
regenerate configure, then I rebuilt and reinstalled freeciv. I _immediately_
encountered another bug. My civclient, linked with SDL_mixer, dumped core at
civclient:/usr/local/lib/libSDL_mixer.so.3.0: civclient : WARNING:
t_filename) size mismatch, relink your program
Segmentation fault (core dumped)
I found two global variables named 'current_filename': one in civclient (an
ELF executable) and one in SDL_mixer (an ELF shared library). The 'WARNING:'
line comes from /usr/libexec/ld.so, the dynamic linker for ELF shared
libraries. ELF seems to have one level of symbol resolution, so
'current_filename' can be only one variable. To solve the conflict, I must
rename one of the two variables.
In civclient, client/connectdlg_common.[ch] declares a global variable named
'current_filename', sized 4 bytes. My libSDL_mixer.so.3.0 declares a
different global variable also named 'current_filename', sized 1024 bytes.
$ readelf -s /usr/local/lib/libSDL_mixer.so.3.0 |
> fgrep current_filename
234: 0008fe10 1024 OBJECT GLOBAL DEFAULT 27 current_filename
I think that my libSDL_mixer.so.3.0 is wrong to export 'current_filename',
but I am too lazy to fix and rebuild SDL_mixer. So I instead added a '#define
current_filename freeciv_current_filename' to client/connectdlg_common.h in
Then I rebuilt and reinstalled freeciv, and the civclient had perfect sound!
The attached freeciv-detect-sdl-mixer.patch edits both m4/sound.m4 and
client/connectdlg_common.h. This allows configure to detect SDL_mixer, and
prevents the 'current_filename' conflict. Remember to run 'aclocal -I m4' and
'autoconf' after applying the patch.
Please fix this bug in the next version of freeciv.
Date: Thursday 11/12/2009 at 21:15 Name: freeciv-detect-sdl-mixer.patch
Size: 1kB By: kernigh
diff for both m4/sound.m4 and client/connectdlg_common.h
Reply to this item at:
Message sent via/by Gna!
Freeciv-dev mailing list