From: David B. <dav...@gm...> - 2010-06-13 21:53:03
|
Hi Vikas, >>> I am getting error on compilation of tuxmath. How to link the library >>> libxml2-devel with makefile.am (if I am right)? >> >> I believe this is (or should be) done in configure.ac, not Makefile.am . That's correct - configure.ac is how you determine what gets checked when you run ./configure, which is when our package checks to see if it the needed libs are available and sets the compilation flags. As part of getting the mingw-cross-env crossbuild working, I recently revised tuxmath's configure.ac fairly heavily with a lot of help from Volker, mingw-cross-env's maintainer. Basically, the simple way to check for a library with autoconf is with AC_CHECK_LIB. However, that isn't sufficient for making a completely statically-linked program like mingw-cross-env does, because all of the secondary dependencies must be known at compile time. If possible, pkg-config's PKG_CHECK_MODULES is a more reliable way to make sure all the dependencies are correctly linked. However, pkg-config isn't supported for all libraries on all systems. Thus, we now use a two-tier approach - attempt to find the lib first with PKG_CHECK_MODULES, then fall back to AC_CHECK_LIB if needed. Below is how this approach is used for SDL_mixer. We should be able to adapt this by substituting "libxml-2.0" for "SDL_mixer", "XML" for "SDL_MIXER", etc. (Note: One slight problem I have had since going to this two-step check relates to the echo statements. Without these statements, the output from configure is confusing because it show the PKG_CHECK_LIB step failing, then the AC_CHECK_LIB step succeeding, without a very clear indication that it is a fallback check. With the echo statements, I had to put in another set of [] brackets, which causes autoconf to complain/fail on the first attempt (apparently from overquoting), but it succeeds and apparently works properly if run a second time. If anyone has a good fix for this, I would be most appreciative). Regards, David Bruce Excerpt from tuxmath's configure.ac: ----------------------------- dnl Check for SDL_mixer: -------------------------------------------------------- PKG_CHECK_MODULES([SDL_MIXER], [SDL_mixer], , [ [echo "SDL_MIXER not found via pkg_config, checking with AC_CHECK_LIB:"] AC_CHECK_LIB([SDL_mixer], [Mix_OpenAudio], , [AC_MSG_ERROR([SDL_mixer not found! http://www.libsdl.org/projects/SDL_mixer])] ) [echo "SDL_MIXER successfully located"] ] ) AC_DEFINE([HAVE_LIBSDL_MIXER],[1],[Define to 1 if you have the `SDL_mixer` library]) CFLAGS="$CFLAGS $SDL_MIXER_CFLAGS" LIBS="$LIBS $SDL_MIXER_LIBS" |