If the include you need is in /usr/local/include dont include the
one in /usr/include.

-moj

On Wed, 19 Mar 2008, Michael Spratt wrote:

on openbsd4.2 installed db-3.1.17p8
trying to compile this simple c program using the BerkeleyDB
Could anyone help me trouble shoot my cc line optons? I believe there is a
problem with the program seing the library? I want to statically link the
libray.

include dir is /usr/local/include/db
# pwd
/usr/local/lib/db
# ls
libdb.a           libdb.la          libdb.so.3.1      libdb_cxx.a
libdb_cxx.la      libdb_cxx.so.4.0

lib dir is /usr/local/lib/db
# pwd
/usr/local/include/db
# ls
db.h     db_185.h db_cxx.h

CODE------
#include <sys/types.h>
#include <stdio.h>
#include <db.h>

#define DATABASE "access.db"

int
main()
{
       DB *dbp;
       int ret;

       if ((ret = db_create(&dbp, NULL, 0)) !=0) {
               fprintf(stderr, "db_creat: %s\n", db_strerror(ret));
               exit(1);
       }

}

COMPILE OUTPUT-------------
# cc t2.c
/tmp//ccdm8869.o(.text+0x1c): In function `main':
: undefined reference to `db_create'
/tmp//ccdm8869.o(.text+0x32): In function `main':
: undefined reference to `db_strerror'
collect2: ld returned 1 exit status

Reply via email to