Re: Connecting - Need Help !

From: Christoph Haller <ch(at)rodos(dot)fzk(dot)de>
To: pgmoscatt(at)optushome(dot)com(dot)au, pgsql-interfaces(at)postgresql(dot)org
Subject: Re: Connecting - Need Help !
Date: 2003-07-15 10:46:47
Message-ID: 3F13DB97.833A868E@rodos.fzk.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-interfaces

>
> 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 ??

Looks like you didn't link libpq.
Something similar to -L$PGSQLD/lib/ -lpq should appear in LDFLAGS
resp. LIBS.
Regards, Christoph
PS Your code looks like C, but from your directory name one could think
it's C++.
Just wondering.

Browse pgsql-interfaces by date

  From Date Subject
Next Message Bruno Wolff III 2003-07-15 13:31:04 Re: Backend Server v's Frontend Server ?
Previous Message Peter Moscatt 2003-07-15 09:28:09 Connecting - Need Help !