[prog] GNU autotools and namespaced libraries

John Clarke johnc+linuxchix at kirriwa.net
Thu Dec 16 16:33:59 EST 2004


On Wed, Dec 15, 2004 at 10:48:58 -0600, Meredith L. Patterson wrote:

> So, if I change it to a function which has an extern declaration (in 

By "extern declaration", I'm assuming you mean that it's inside an
'extern "C" { ... }" block, i.e. it has C linkage and isn't name
mangled.

> this case, pqxxNoticeCaller, which takes a couple of parameters, but 
> that's another issue), I get the following:
> 
> configure:1263: checking for pqNoticeCaller in -lpqxx
> configure:1282: gcc -o conftest -g -O2   conftest.c -lpqxx  -lpopt  1>&5
> /usr/lib/gcc-lib/i686-pc-linux-gnu/3.3.4/../../../libpqxx.so: undefined 
> referenceto `__cxa_free_exception'

I'd guess that this is because you haven't told AC_CHECK_LIB to link
with the libraries that libpqxx needs (and anything that those libraries
also need).  You'll probably need libstdc++ -- gcc, unlike g++, doesn't
automatically include it in the link.

>From the description of AC_CHECK_LIB:

    If linking with LIBRARY results in unresolved symbols, which would
    be resolved by linking with additional libraries, give those
    libraries as the OTHER-LIBRARIES argument, separated by spaces:
    `-lXt -lX11'.  Otherwise this macro will fail to detect that LIBRARY
    is present, because linking the test program will always fail with
    unresolved symbols.

> a using declaration, So, if I can rewrite AC_CHECK_LIB to include 
> namespace support, d'you reckon it's likely to work as long as I check 
> for a function with an extern declaration?

I'd expect it to, once you include the extra libraries in the
AC_CHECK_LIB call.

> Alternately, is there another way to make sure that libpqxx is linked 
> against, without using AC_CHECK_LIB?

If it's not optional, you can simply use LIBS="$LIBS -lpqxx".  That will
include the library in all links from then on.  I wouldn't do that
though; I'd check for it and report an error if it can't be found.  I'd
also include a check for any associated header files, before checking
for the library.


Cheers,

John
-- 
> Don't mess with the Swedish, or they'll talk Swedish at you.
It could be worse. It could be Dutch, and you'd have to keep wiping the
spittle off your face
            -- Paul Martin


More information about the Programming mailing list