[Top][All Lists]

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

AC_CHECK_LIB fails to locate a C++ library

From: Eric Hanchrow
Subject: AC_CHECK_LIB fails to locate a C++ library
Date: 18 Oct 2001 10:20:27 -0700
User-agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.0.106

This might be a bug, or it might just be that I'm misunderstanding
something.  (I would have checked the mailing list archive to see if
this has already been reported, but as far as I can tell, I'd need to
either check about 30 separate monthly archives by hand -- ugh -- or
download a 15Mb file.  Neither option is feasible.)
Anyway, here's what I did, what I saw, and what I expected:

* I created a `configure.in' with this content:

    AC_CHECK_LIB(cppunit, [CppUnit::TestCase::TestCase])

* I created an empty hello.cc with `touch hello.cc'

* I ran autoconf 2.50

* I ran the resulting `configure' script

As `configure' ran, it printed this:

        checking for CppUnit::TestCase::TestCase in -lcppunit... no

This surprised me, since I indeed have a library named `cppunit' on my
path, and it does indeed contain a function with that name; naturally
I expected the check to succeed.

Here's what I saw in config.log:

    configure:1358: g++ -o conftest -g -O2   conftest.cc -lcppunit   >&5
    configure:1347: syntax error before `::'
    configure: In function `int main()':
    configure:1351: `CppUnit' undeclared (first use this function)
    configure:1351: (Each undeclared identifier is reported only once
    configure:1351: for each function it appears in.)
    configure:1351: parse error before `::'
    configure:1361: $? = 1
    configure: failed program was:
    #line 1339 "configure"
    #include "confdefs.h"

    /* 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 CppUnit::TestCase::TestCase ();
    main ()
    CppUnit::TestCase::TestCase ();
      return 0;
    configure:1378: result: no

The program `conftest.cc' seems wrong to me: that's not a reliable way
to test for the presence of a C++ function in a library.
Unfortunately, I cannot think of a better way.  This makes me wonder
if I've misunderstood the intent of AC_CHECK_LIB -- perhaps it wasn't
designed to do what I'm trying to do.  (And yet the documentation
clearly says

     Depending on the current language(*note Language Choice::), try to
     ensure that the C, C++, or Fortran 77 function FUNCTION is

, so ...)

In any case, this problem isn't fatal: I'm able to reliably detect the
library using AC_TRY_LINK.  But doing so is a bit more complicated
than AC_CHECK_LIB would be.

So: is this a bug, or am I misunderstanding something?

Please respond directly to me, as I don't read this mailing list, blah
blah blah.


PGP Fingerprint: 3E7B A3F3 96CA 8958 ACC5  C8BD 6337 0041 C01C 5276

reply via email to

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