autoconf
[Top][All Lists]
Advanced

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

Re: Objections? Re: Checking for CXX libraries -- AC_CXX_CHECK_LIB ?


From: Steve M. Robbins
Subject: Re: Objections? Re: Checking for CXX libraries -- AC_CXX_CHECK_LIB ?
Date: Sun, 29 Sep 2002 15:42:36 -0400
User-agent: Mutt/1.4i

On Sun, Sep 29, 2002 at 03:05:35PM -0400, Allan Clark (reply to list only) 
wrote:
> I'm looking here for objections from the AutoConf list.
> 
> 
> I could probably have a version tonight or tomorrow that ignores the
> copied LANG(C)->LANG(C+) stuff and looks something like this:
> 
> AC_CXX_CHECK_LIB(library, function, params, [action-if-found],
> [action-if-not-found], [other-libraries]) 
> 
> ... really adding "params" in there before the optionals.  I could get
> this together, test it myself, and have Sebastian Huber, jlm, and Ossama
> Othman (recent requestors) test it out to see if it works for them. 
> Forgive me if I commit syntactical errors; I'm chronically looking
> things up.
> 
> The function above would generate a call something like:
> 
> AC_CXX_CHECK_LIB(<lib>, pipes::pipeCheck, [(char *) "test", (int) 42])
> 
> ... generating:
> 
>       (void) pipes::pipeCheck ((char *) "test", (int) 42)


Separating the function name and the function parameters in this
way strikes me as clumsy.  It also doesn't allow checking
for a particular class, as you noted later.  Also, you need some
way to specify headers to include for the library.

I have for some time been using a macro that runs TRY_LINK on an arbitrary
piece of code, so you'd write your example as

    AC_CXX_CHECK_LIB( <foo>, 
                      [#include <foo.h>], 
                      [pipes::pipeCheck("test", 42);])

Since the third argument is arbitrary code, it could just as easily
have been an object instantiation to check for a templated library.

Actually, my macro assumes that the library is required for building
and so uses MSG_ERROR if the lib is not found.  This makes it a lot
simpler, but your proposal with [action-if-found], [action-if-not-found],
etc is better.


dnl @synopsis mni_REQUIRE_LIB(LIBRARY,INCLUDES,BODY)
dnl
dnl @version $Id: mni_REQUIRE_LIB.m4,v 1.1 2001/08/20 16:51:50 stever Exp $
dnl @author Steve M. Robbins <address@hidden>


AC_DEFUN([mni_REQUIRE_LIB],
[
  AC_MSG_CHECKING([for library $1])
  LIBS="-l$1 $LIBS"
  AC_TRY_LINK([$2],[$3],[mni_result=yes],[mni_result=no])
  AC_MSG_RESULT([$mni_result])
  if test "$mni_result" = "no"; then
    AC_MSG_ERROR([cannot find required library $1])
  fi
])


So maybe I've missed the point entirely: it seems that all you want
is something that sets the LIBS variable and then calls TRY_LINK?


Regards,
-Steve




reply via email to

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