0

I'm trying to bundle up a small C++ program using automake and autotools. In my current setup, a required library is installed in a location that the configure script is able to find, but is not found when invoking g++ from make.

I can fix this by passing in the relevant -I option when calling configure (such that the proper include path is passed along to the compiler), but I'd prefer that the configure script to fail to find the library whenever make cannot find it either.

Alternatively, I'd like the configure script to generate the necessary -I commands so that the compiler finds everything it needs.

Is there some standard way to do this?

Samveen
  • 3,482
  • 35
  • 52
ChrisB
  • 4,628
  • 7
  • 29
  • 41
  • 1
    Would you give the relevant portions of the output of both the configure and make commands? – Samveen May 18 '12 at 18:58
  • Yes, the relevant output in configure.log is ``gcc -o conftest -I/usr/local/include -I/sw/include -L/usr/local /lib -L/sw/lib conftest.c -lCCfits >&5`` which succeeds. The relevant line from make is ``g++ [...irrelevant flags...] -MMD -g -O2 -MT DendroFits.o -MD -MP -MF .deps/DendroFits.Tpo -c -o DendroFits.o DendroFits.cpp`` which fails with ``DendroFits.h:14:18: warning: CCfits: No such file or directory`` – ChrisB May 19 '12 at 13:56
  • Please add greater detail and add that into the question itself. Also, it seems from the output that the header file `DentroFits.h` is unable to find the definition of `CCFits`. Please check if the relevant headers have been included into this header. – Samveen May 20 '12 at 05:53
  • -I is useful for finding headers, but is totally irrelevant when finding libraries. Probably your configure script is only checking for the existence of the headers and is not checking for the existence of the libraries. – William Pursell May 21 '12 at 19:18

1 Answers1

1

your configure script might be broken, or your interpretation of configure's output:

if your library-check during configure checks whether it can link against a certain library, this does by no means guarantee that you have the required headers available (or findable) to compile.

you should therefore add checks to your configure.ac for both the library and the headers

AC_CHECK_LIB([foo], [foo_init])
AC_CHECK_HEADERS([foo.h])

and only assume that you can build if both lib & headers are present.

if headers cannot be found and you have a good idea where they are, you could add those paths (within configure) and re-run the tests. given that you have to add pretty standard paths ('/usr/local/include' should be part of the automated search paths in any case; '/sw/include' is part of fink, so you should make sure that you initialized your system properly by running

$ . /sw/bin/init.sh

in ther terminal (leave out the '$') before trying to run ./configure

umläute
  • 28,885
  • 9
  • 68
  • 122