[prog] GNU autotools and namespaced libraries

John Clarke johnc+linuxchix at kirriwa.net
Thu Dec 16 17:12:03 EST 2004


On Wed, Dec 15, 2004 at 11:53:02 -0600, Meredith L. Patterson wrote:

> AC_CHECK_LIB(pqxx, PQenv2encoding, , , [-lstdc++])

[snip]

> Sneaky, but it worked -- I guess because PQenv2encoding is unmangled, 
> not in a namespace, parameterless, and still technically part of libpqxx 
> even though it doesn't actually live in it.

You're looking for PQenv2encoding in libpqxx, but it's actually in
libpq.  You haven't told AC_CHECK_LIB to include libpq in the link, so
how does it find it?

There are only two ways I can think of for this to work:

1.  You've already checked for libpq, so it's been added to $LIBS and so
    included in any later link.  If this is the case, you're only
    checking that there's a libpqxx, but it doesn't matter what's in it.
    As long as the linker can open the file, the test will pass.

2.  libpqxx is statically linked with libpq.  In this case, the test is
    doing exactly what you want and your hack is fine.  It's not really
    a hack because it's testing for a function which is in that library 
    That the library is built from both C and C++ code is irrelevant.

> Thanks again, John!

You're welcome, again :-)


Cheers,

John
-- 
I just had a look at 0xBEDEAD; it reminds me of a color popular
in Elizabethan England under the name "Dead Spaniard".
            -- Mike Andrews


More information about the Programming mailing list