1

I have implemented a logging library in C (which I've named liblogger), and used Autotools to compile and install it. As far as I can see, the installation is correctly done, since the headers and the library itself (which I currently bundle into a static library) are installed into the appropriate directories (/usr/local/include/liblogger/ for the headers and /usr/local/lib for the .a).

Now I am trying to link another tool with that library (compiled and built also using Autotools). To check for the logging library presence, I have followed what is said here to create the configure.ac file. But the resulting configure script says:

checking /usr/local/include/liblogger/logger.h usability... no

checking /usr/local/include/liblogger/logger.h presence... no

checking for /usr/local/include/liblogger/logger.h... no

checking for log_init in -l/usr/local/lib/liblogger.a... no

even though the named files DO exist.

The part of the configure.ac file where I check for the header and the library is as follows:

LIBLOGGER=/usr/local/lib
HEADERLOGGER=/usr/local/include/liblogger

AC_CHECK_HEADER([${HEADERLOGGER}/logger.h],
    [AC_DEFINE([HAVE_LOGGER_H], [1], [found logger.h])
    CFLAGS="$CFLAGS -I${HEADERLOGGER}"])

AC_CHECK_LIB([${LIBLOGGER}/liblogger.a],
    log_init, [found liblogger.a], [], [])

AC_SUBST(LIBLOGGER)

Actually, if I try with:

AC_CHECK_FILE(
   [${HEADERLOGGER}/logger.h],
   [AC_MSG_NOTICE([Found logger.h])],
   [AC_MSG_NOTICE([Didn't find logger.h])]
   )

it does find the file.

Thanks.

Community
  • 1
  • 1
Ginswich
  • 264
  • 3
  • 13
  • are file permissions ok ? – SirDarius Jan 08 '13 at 13:53
  • Yes, they are (644, I even tried with 777, just in case). – Ginswich Jan 08 '13 at 15:12
  • The problem might reside in your configure.ac files. would it be ok for you to post some of their contents relevant to this issue ? – SirDarius Jan 08 '13 at 15:15
  • 1
    You should not be setting `LIBLOGGER` or `HEADERLOGGER` in the `configure.ac` of the dependent package. Instead, just do `AC_CHECK_HEADER([logger.h])` and make sure that `-I/usr/local/include` is in CPPFLAGS and `-L/usr/local/lib` is in LDFLAGS when you run configure. The trouble with hard coding a path in configure.ac is that it will completely break when someone puts the library somewhere else. – William Pursell Jan 08 '13 at 18:00
  • @WilliamPursell Thank you for the advise. However, the problem with what you say is that (I haven't yet been able to determine why), the _configure_ script is not looking into `/usr/local/include` for the headers... – Ginswich Jan 09 '13 at 09:20
  • @Ginswich The configure script is not looking in `/usr/local/include` for headers because you have not told the preprocessor to look there. You must put `-I/usr/local/include` in CPPFLAGS (or use some other mechanism). Whatever you do, it is to be done by the user (the person who runs `configure`), not the maintainer (the person who builds `configure` via `autoconf`). – William Pursell Jan 09 '13 at 12:59

1 Answers1

2

The problem was not on the tool's configure.ac, but in the original logger library. When inspecting the config.log file generated when running the configure script, there was a line saying:

/usr/local/include/liblogger/logger.h:22:19: fatal error: types.h: No such file or directory

So I actually had to reorganize some dependencies in the logger library.

In fact, setting HEADERLOGGER to liblogger doesn't solve the problem, since (I don't know why), "/urs/local/include/liblogger" is not being searched for, returning

configure: error: Couldn't find liblogger/logger.h

(Perhaps I'm forgetting some previous AC instruction for that).

The moral: the log files are there for a reason... :-S

Ginswich
  • 264
  • 3
  • 13