[Top][All Lists]

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

RE: Checking for libraries

From: Tim Van Holder
Subject: RE: Checking for libraries
Date: Fri, 26 Jan 2001 18:45:57 +0100

> AC_CHECK_LIB(JTC, notifyAll)
> It responds that it cannot find it. Yet I look in the directory and its
> there. I run "grep notifyAll" and it says the binary has a
> match. I know that function exists in the library.
> So I am confused why its not working
Given that it's a C++ library, might it be that the library either uses
C++ linkage, or has the function in a namespace? configure will try to
compile the following to check for libJTC:

/* Override any gcc2 internal prototype to avoid an error.  */
#ifdef __cplusplus
extern "C"
/* We use char because int might match the return type of a gcc2
   builtin and then its argument prototype would still apply.  */
char notifyAll ();

  notifyAll ();
  return 0;

So if notifyAll() takes no parameters, this would work (as
"char notifyAll ()" is treated as "char notifyAll (void)" in C++.
If it takes parameters, name mangling will ensure the linker can't
find it. Same goes if it's in a namespace. In either of the last
two cases, you'll need to write your own macro - something like:

// if it's a param thing
int notifyAll(foo, const bar&);
// if it's a namespace thing
namespace JTC {
  void notifyAll(void);
using JTC::notifyAll;
], [notifyAll();],
[my_check_lib_jtc_found=yes], [my_check_lib_jtc_found=no])
AS_IF([test x$my_check_lib_jtc_found = xyes],
      [AC_DEFINE(HAVE_LIBJTC, 1, [Define if you have the JTC library.])

Put the above in aclocal.m4, and call it in
Note: the above macro comes with NO warranty of any kind, yadda
yadda; I probably made some (several?) mistakes, but I'm sure the
experts on this list will be quick to set me straight :-)

I suppose autoconf could/should be extended to handle namespaces/params
when looking for C++-based libraries. I'll see if I can get a patch

reply via email to

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