pg.ddx.io pgsql-interfaces@postgresql.org mailing list archive
help / color / mirror / Atom feedRe: Connecting - Need Help !
3+ messages / 3 participants
[nested] [flat]
* Re: Connecting - Need Help !
@ 2003-07-14 14:00 Darko Prenosil <Darko.Prenosil@finteh.hr>
parent: Peter Moscatt <pgmoscatt@optushome.com.au>
0 siblings, 0 replies; 3+ messages in thread
From: Darko Prenosil @ 2003-07-14 14:00 UTC (permalink / raw)
To: pgmoscatt@optushome.com.au; pgsql-interfaces
----- Original Message -----
From: "Peter Moscatt" <pgmoscatt@optushome.com.au>
To: "PostgreSQL [INTERFACES] List" <pgsql-interfaces@postgresql.org>
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 !
^ permalink raw reply [nested|flat] 3+ messages in thread
* Connecting - Need Help !
@ 2003-07-15 09:28 Peter Moscatt <pgmoscatt@optushome.com.au>
0 siblings, 1 reply; 3+ messages in thread
From: Peter Moscatt @ 2003-07-15 09:28 UTC (permalink / raw)
To: 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 ??
Pete
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: Connecting - Need Help !
@ 2003-07-15 10:46 Christoph Haller <ch@rodos.fzk.de>
0 siblings, 0 replies; 3+ messages in thread
From: Christoph Haller @ 2003-07-15 10:46 UTC (permalink / raw)
To: pgmoscatt@optushome.com.au; 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.
^ permalink raw reply [nested|flat] 3+ messages in thread
end of thread, other threads:[~2003-07-15 10:46 UTC | newest]
Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2003-07-15 09:28 Connecting - Need Help ! Peter Moscatt <pgmoscatt@optushome.com.au>
2003-07-14 14:00 ` Darko Prenosil <Darko.Prenosil@finteh.hr>
2003-07-15 10:46 Re: Connecting - Need Help ! Christoph Haller <ch@rodos.fzk.de>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox