0

I'm using an autoconf/automake configure script on cygwin, and I have the problem that it doesn't fin my dependencies.

For example I do, in my configure.ac:

AC_CHECK_LIB(mp3lame,lame_init,,AC_MSG_ERROR(Required library LAME not found.)) AC_CHECK_HEADER(lame/lame.h,,AC_MSG_ERROR(Headers for LAME not found.))

To find lame. Lame is installed, if I do locate lame.h I find it in /usr/local/include/lame/lame.h. Now, if I set LIBRARY_PATH and INCLUDE_PATH with

export INCLUDE_PATH=/usr/local/include/ export LIBRARY_PATH=/usr/local/lib/

It works as expected. I have installed lame by downloading it and running:

./configure
make
make install 

So I would think that it should end up in a "standard enough" path for my configure script to find it. In a similar way, I'm checking for the json parser jansson using:

PKG_CHECK_MODULES(JANSSON,jansson)

And it doesn't find it unless I do:

export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig/

Is this a problem with cygwin (I wouldn't think so) or a problem with my configure.ac script?

Mikael Lindqvist
  • 775
  • 5
  • 21

1 Answers1

1

This is not a problem with cygwin, nor with your configure.ac. It is a "feature" of PKG_CHECK_MODULES and is one of the reasons I recommend against using it. If a configure script generated from a configure.ac that uses PKG_CHECK_MODULES is used, it is necessary that the user set PKG_CONFIG_PATH. The best approach is to use AC_CHECK_LIB instead of PKG_CHECK_MODULES. You are absolutely correct that ./configure && make && make install gives you a standard installation that should work. The problem is that PKG_CHECK_MODULES does not play well with standard installations.

William Pursell
  • 204,365
  • 48
  • 270
  • 300
  • Thank you for your answer!! Ok I see, the problem is that AC_CHECK_LIB (which I also use) requires me to set LIBRARY_PATH, using "export LIBRARY_PATH=/usr/local/lib/" so it doesn't work with a standard installation either. Any way around this? – Mikael Lindqvist Jun 19 '12 at 12:33
  • There are several typical solutions: add /usr/local/lib to the standard list of locations searched by the linker (eg append a line to /etc/ld.so.conf), put the path in LIBRARY_PATH in the environment, or put a config.site in /usr/local/share that adjusts LIBRARY_PATH as required. – William Pursell Jun 19 '12 at 15:55
  • Yes I can do that ofcourse. But it seems strange to me that I have to do that. Usually when I download some open source software from the internet and type "./configure && make && make install" it "just works". I would like to be able to create configure scripts that "just works" too, so that the user doesn't have to fiddle around and set environment variables before running the script. – Mikael Lindqvist Jun 21 '12 at 11:25
  • Maybe there is some practice for adding some more semi-standard search paths to my configure script. In the best of worlds, that's exactly what auto tools and so on should do, but I can understand that this is not the best of worlds, it's kind of a moving target... – Mikael Lindqvist Jun 21 '12 at 11:28
  • And just to make sure... The solutions you suggest ("...add /usr/local/lib to the standard list...") and (..."put the path in LIBRARY_PATH in the environment"...) that's something that would have to be done on the machine where my software is installed, right? I have no control over that machine, since it might be any machine where a user wants to install my software. – Mikael Lindqvist Jun 21 '12 at 11:32
  • It typically does "just work", but only if all of the dependencies are installed in locations searched by the tool chain. If the computer is configured so that the tool chain looks in /usr/local for libraries, then the user need do nothing extra. If not, the user can set LDFLAGS and CPPFLAGS or do some platform specific tweaks. (Setting LIBRARY_PATH works with gcc, and is platform specific.) – William Pursell Jun 21 '12 at 11:37
  • But it is kind of strange then, that cygwin installs libraries in /usr/local/lib/, but still it doesn't set up things so that this path will be searched. It could event be called a "bug" in cygwin, imo. Would you agree? – Mikael Lindqvist Jun 21 '12 at 16:48
  • @Mikael I don't think it's a bug in cygwin, but it could reasonably argued that it is a deficiency in autoconf. It seems reasonable that the configure script should look in $libdir, but that is difficult to do generically since there are many different ways to tell the toolchain where to look. It seems reasonable for the configure script to add `-L${libdir}` to LDFLAGS and `-I$prefix/include` to CPPFLAGS, but simple things like that are often a Pandora's box and it is really best to let the user handle it. – William Pursell Jun 21 '12 at 16:59