X-Original-To: pgsql-interfaces-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.225.181]) by svr1.postgresql.org (Postfix) with ESMTP id F2C9ACC3B9 for ; Tue, 15 Jul 2003 13:56:01 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (svr5.postgresql.org [64.117.225.181]) (amavisd-new, port 10024) with ESMTP id 17639-09 for ; Tue, 15 Jul 2003 13:56:15 +0000 (GMT) Received: from mail.iskon.hr (mail.iskon.hr [213.191.128.4]) by svr1.postgresql.org (Postfix) with SMTP id 3C748CC3AA for ; Tue, 15 Jul 2003 10:55:49 -0300 (ADT) Received: (qmail 25366 invoked from network); 15 Jul 2003 15:56:16 +0200 Received: from zg05-028.dialin.iskon.hr (HELO darko) (213.191.138.29) by mail.iskon.hr with SMTP; 15 Jul 2003 15:56:16 +0200 Message-ID: <001a01c34a10$88f62230$1d8abfd5@darko> From: "Darko Prenosil" To: , "PostgreSQL [INTERFACES] List" References: <1058261289.3691.4.camel@localhost> Subject: Re: Connecting - Need Help ! Date: Mon, 14 Jul 2003 16:00:56 +0200 MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-2" Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2600.0000 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2600.0000 X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200307/23 X-Sequence-Number: 4337 ----- Original Message ----- From: "Peter Moscatt" To: "PostgreSQL [INTERFACES] List" Sent: Tuesday, July 15, 2003 11:28 AM Subject: [INTERFACES] Connecting - Need Help ! > I am trying my first attempt to write code which will conect to a test > database I have created. > > The code I used is shown below: > > void ConnectDatabase() > { > char *pghost; > char *pgport; > char *pgoptions; > char *pgtty; > char *dbName; > > PGconn *conn; > PGresult *res; > > pghost = NULL; > pgport = NULL; > pgoptions = NULL; > dbName = "linlog"; > > conn = PQsetdb(pghost,pgport,pgoptions,pgtty,dbName); > } > > > > > When I compile and make I get the following error: > > linlog.o(.text+0x177): In function `ConnectDatabase()': > /home/pmoscatt/C++/linlog/linlog/linlog.cpp:30: undefined reference to > `PQsetdbLogin' > collect2: ld returned 1 exit status > gmake[2]: *** [linlog] Error 1 > gmake[2]: Leaving directory `/home/pmoscatt/C++/linlog/linlog' > gmake[1]: Leaving directory `/home/pmoscatt/C++/linlog' > gmake[1]: *** [all-recursive] Error 1 > gmake: *** [all-recursive-am] Error 2 > *** failed *** > > > > What have I done wrong here ?? > > Pete > It is not compile, but linking problem. You should link Your program with libpq library, which is usually done by writing something like: LDFLAGS = -L/usr/local/pgsql/lib -lpq to Makefile, but it depends on build system You are using. Regards !