URL:
  <http://gna.org/bugs/?14751>

                 Summary: configure fails to detect SDL_mixer
                 Project: Freeciv
            Submitted by: kernigh
            Submitted on: Thursday 11/12/2009 at 21:15
                Category: client
                Severity: 2 - Minor
                Priority: 5 - Normal
                  Status: None
             Assigned to: None
        Originator Email: 
             Open/Closed: Open
                 Release: 2.1.9
         Discussion Lock: Any
        Operating System: *BSD
         Planned Release: None

    _______________________________________________________

Details:

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
CPPFLAGS=-I/usr/local/include LDFLAGS=-L/usr/local/lib

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
-I/us
r/X11R6/include -DXTHREADS
$ 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
in /usr/X11R6.)

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
'SDL_mixer.h').

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
startup.


$ civclient
civclient:/usr/local/lib/libSDL_mixer.so.3.0: civclient : WARNING:
symbol(curren
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
freeciv.

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.



    _______________________________________________________

File Attachments:


-------------------------------------------------------
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
<http://gna.org/bugs/download.php?file_id=7297>

    _______________________________________________________

Reply to this item at:

  <http://gna.org/bugs/?14751>

_______________________________________________
  Message sent via/by Gna!
  http://gna.org/


_______________________________________________
Freeciv-dev mailing list
Freeciv-dev@gna.org
https://mail.gna.org/listinfo/freeciv-dev

Reply via email to