C compilation problem using autotools

L

Lowell Kirsh

I don't know much about autotools or Berkeley db (bdb) but they are
being used by a program I'm trying to compile and it's causing me
problems. The line which is the culprit is in a configure.ac file and it's:

AC_CHECK_LIB(db, db_create, ,AC_MSG_ERROR([Berkeley db library not found]))

This is what ends up causing the configure script to fail. The thing is,
I am pretty sure I have the newest bdb installed on my system. I am able
to compile the following bdb-dependent file, which I would think is a
sign that I have bdb installed:

#include <db.h>
int main() { db_create(0,0,0); }

So to test it out, I read an autotools tutorial and created a tiny
configure.ac file:

AC_INIT(dbtest.c)
AC_CHECK_LIB(db, db_create, ,AC_MSG_ERROR([Berkeley db library not found]))

This generates a configure file which fails with the following message:

checking for db_create in -ldb... no
configure: error: Berkeley db library not found

It's strange, like I both have bdb and don't have it, at the same time.
Anyone have any idea what's the matter?

Thanks in advance,
Lowell
 
U

Ulrich Eckhardt

Lowell said:
I don't know much about autotools or Berkeley db (bdb) but they are
being used by a program I'm trying to compile and it's causing me
problems. The line which is the culprit is in a configure.ac file and
it's:

AC_CHECK_LIB(db, db_create, ,AC_MSG_ERROR([Berkeley db library not
found]))

This is what ends up causing the configure script to fail. The thing is,
I am pretty sure I have the newest bdb installed on my system. I am able
to compile the following bdb-dependent file, which I would think is a
sign that I have bdb installed:

#include <db.h>
int main() { db_create(0,0,0); }

And what does autoconf do for a test? Anyhow, are you sure db_create is a
function and not a macro? Are there perhaps versioned symbols interfering?
How about not using AC_CHECK_LIB but AC_TRY_LINK with above snippet? Dow
do other projects figure out if BDB is available?

Apart from the possibility of a macro, all these are not strictly on-topic
here btw, and it seems you didn't even look at the logs, or?

Uli
 
L

Lowell Kirsh

Ulrich said:
And what does autoconf do for a test?
I'm not sure what you mean by this?
Anyhow, are you sure db_create is a
function and not a macro?
No, I think it is actually a macro. From /usr/include/db.h:
#define db_create db_create_4002
I've grepped for db_create_4002 but couldn't find its definition
anywhere. This kinda stuff is beyond the C I'm used to so I wasn't sure
what kind of magic was going on in the header file.
> Are there perhaps versioned symbols interfering?
I don't know what that means.
How about not using AC_CHECK_LIB but AC_TRY_LINK with above snippet? Dow
do other projects figure out if BDB is available?
The reason I was using AC_CHECK_LIB was that was the function that was
used by this program I'm trying to compile.
I'm on a new system and have been installing everything with apt-get, so
I don't think I've had a chance to compile anything else yet that
depended on bdb.
Apart from the possibility of a macro, all these are not strictly on-topic
here btw, and it seems you didn't even look at the logs, or?

here's the relevant part of the log. The thing that I didn't get was why
that bit of code below doesn't #include <db.h> which would have allowed
i to succeed.


configure:2171: checking for db_create in -ldb
configure:2201: gcc -o conftest -g -O2 conftest.c -ldb >&5
/tmp/cc21eNUB.o(.text+0xa): In function `main':
/home/lkirsh/temp/dbtest/conftest.c:20: undefined reference to `db_create'
collect2: ld returned 1 exit status
configure:2207: $? = 1
configure: failed program was:
| /* confdefs.h. */
|
| #define PACKAGE_NAME ""
| #define PACKAGE_TARNAME ""
| #define PACKAGE_VERSION ""
| #define PACKAGE_STRING ""
| #define PACKAGE_BUGREPORT ""
| /* end confdefs.h. */
|
| /* Override any gcc2 internal prototype to avoid an error. */
| #ifdef __cplusplus
| extern "C"
| #endif
| /* We use char because int might match the return type of a gcc2
| builtin and then its argument prototype would still apply. */
| char db_create ();
| int
| main ()
| {
| db_create ();
| ;
| return 0;
| }
configure:2232: result: no
configure:2242: error: Berkeley db library not found
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,159
Messages
2,570,879
Members
47,417
Latest member
DarrenGaun

Latest Threads

Top