From owner-freebsd-current@FreeBSD.ORG Mon Apr 7 15:10:55 2003 Return-Path: Delivered-To: freebsd-current@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id DD50137B401 for ; Mon, 7 Apr 2003 15:10:54 -0700 (PDT) Received: from mail.gmx.net (pop.gmx.de [213.165.65.60]) by mx1.FreeBSD.org (Postfix) with SMTP id BCDD443FB1 for ; Mon, 7 Apr 2003 15:10:53 -0700 (PDT) (envelope-from s.moeck@gmx.de) Received: (qmail 5130 invoked by uid 65534); 7 Apr 2003 22:10:52 -0000 Received: from dsl254-062-177.sea1.dsl.speakeasy.net (HELO xpn) (216.254.62.177) by mail.gmx.net (mp003-rz3) with SMTP; 08 Apr 2003 00:10:52 +0200 From: =?iso-8859-1?Q?Stephan_M=F6ck?= To: Date: Mon, 7 Apr 2003 14:10:36 +0200 Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Priority: 3 (Normal) X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook IMO, Build 9.0.2416 (9.0.2911.0) Importance: Normal X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106 Subject: DB3 problem X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 07 Apr 2003 22:10:55 -0000 I have just installed DB3 and I want to compile an example programm from the examples_c directory. The compilation stops with errors. gcc -o dbtest ex_access.c /var/tmp//ccdld6iZ.o: In function `ex_access': /var/tmp//ccdld6iZ.o(.text+0x5b): undefined reference to `db_create' /var/tmp//ccdld6iZ.o(.text+0x72): undefined reference to `db_strerror' /var/tmp//ccdld6iZ.o(.text+0x444): undefined reference to `db_strerror' Does anybody no what's the problem is? ############################################################### #include #include #include //#include #include //#include #ifdef HAVE_VXWORKS #include "stdio.h" #define ERROR_RETURN ERROR #else #define DATABASE "access.db" #define ERROR_RETURN 1 int main __P((void)); #endif int ex_access __P((void)); #ifndef HAVE_VXWORKS int main() { return (ex_access() == ERROR_RETURN ? EXIT_FAILURE : EXIT_SUCCESS); } #endif int ex_access() { DB *dbp; DBC *dbcp; DBT key, data; u_int32_t len; int ret; char *p, *t, buf[1024], rbuf[1024]; const char *progname = "ex_access"; /* Program name. */ /* Remove the previous database. */ (void)remove(DATABASE); /* Create and initialize database object, open the database. */ if ((ret = db_create(&dbp, NULL, 0)) != 0) { fprintf(stderr, "%s: db_create: %s\n", progname, db_strerror(ret)); return (ERROR_RETURN); } dbp->set_errfile(dbp, stderr); dbp->set_errpfx(dbp, progname); if ((ret = dbp->set_pagesize(dbp, 1024)) != 0) { dbp->err(dbp, ret, "set_pagesize"); goto err1; } if ((ret = dbp->set_cachesize(dbp, 0, 32 * 1024, 0)) != 0) { dbp->err(dbp, ret, "set_cachesize"); goto err1; } if ((ret = dbp->open(dbp, DATABASE, NULL, DB_BTREE, DB_CREATE, 0664)) != 0) { dbp->err(dbp, ret, "%s: open", DATABASE); goto err1; } /* * Insert records into the database, where the key is the user * input and the data is the user input in reverse order. */ memset(&key, 0, sizeof(DBT)); memset(&data, 0, sizeof(DBT)); for (;;) { printf("input> "); fflush(stdout); if (fgets(buf, sizeof(buf), stdin) == NULL) break; if ((len = strlen(buf)) <= 1) continue; for (t = rbuf, p = buf + (len - 2); p >= buf;) *t++ = *p--; *t++ = '\0'; key.data = buf; data.data = rbuf; data.size = key.size = len - 1; switch (ret = dbp->put(dbp, NULL, &key, &data, DB_NOOVERWRITE)) { case 0: break; default: dbp->err(dbp, ret, "DB->put"); if (ret != DB_KEYEXIST) goto err1; break; } } printf("\n"); /* Acquire a cursor for the database. */ if ((ret = dbp->cursor(dbp, NULL, &dbcp, 0)) != 0) { dbp->err(dbp, ret, "DB->cursor"); goto err1; } /* Initialize the key/data pair so the flags aren't set. */ memset(&key, 0, sizeof(key)); memset(&data, 0, sizeof(data)); /* Walk through the database and print out the key/data pairs. */ while ((ret = dbcp->c_get(dbcp, &key, &data, DB_NEXT)) == 0) printf("%.*s : %.*s\n",(int)key.size, (char *)key.data, (int)data.size, (char *)data.data); if (ret != DB_NOTFOUND) { dbp->err(dbp, ret, "DBcursor->get"); goto err2; } /* Close everything down. */ if ((ret = dbcp->c_close(dbcp)) != 0) { dbp->err(dbp, ret, "DBcursor->close"); goto err1; } if ((ret = dbp->close(dbp, 0)) != 0) { fprintf(stderr, "%s: DB->close: %s\n", progname, db_strerror(ret)); return (ERROR_RETURN); } return (0); err2: (void)dbcp->c_close(dbcp); err1: (void)dbp->close(dbp, 0); return (ERROR_RETURN); } #########################################################