[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Check for Library using autoconf

From: J. Scott Amort
Subject: Check for Library using autoconf
Date: 22 Mar 2003 18:27:12 -0800


I am quite new to using autoconf, so please bear with me,

I have a C++ program that requires the log4cpp library to perform
logging functions.  So, I want my program to check for this library when
the user does a ./configure.  Here is the code I have put together to
add to to accomplish this:

AC_PATH_PROG(LOG4CPP_CONFIG, log4cpp-config, no)
if test x$LOG4CPP_CONFIG = xno ; then
  echo "*** log4cpp-config not found. See";
  echo "*** All of log4cpp dependent parts will be disabled"
  AC_MSG_CHECKING(log4cpp version)
  LOG4CPP_VERSION=[`log4cpp-config --version | sed 's/^[^0-9]*//'`]
  AC_DEFINE(HAVE_LIBLOG4CPP,1,[Define to 1 if log4cpp library was
  LOG4CPP_CFLAGS=[`log4cpp-config --cflags`]
  LOG4CPP_LIBS=[`log4cpp-config --libs`]

Feel free to critique my technique, I put this together by trying to
read through the monumental documentation and looking at how other
programs approach similar problems.  I suspect it is a mess, but it does
seem to work!  My problem is that although it will tell me if it finds
the library, and I can pass HAVE_LIBLOG4CPP into my program by including
config.h, I don't know how to get the include path and library names
into the g++ command line (i.e. -I/usr/local/include/log4cpp and
-L/usr/local/lib -llog4cpp -lnsl).  These are of course the values in
LOG4CPP_CFLAGS and LOG4CPP_LIBS.  Could some kind soul offer me some
guidance?  Thanks very much.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]