From: | "Darko Prenosil" <Darko(dot)Prenosil(at)finteh(dot)hr> |
---|---|
To: | <pgmoscatt(at)optushome(dot)com(dot)au>, "PostgreSQL [INTERFACES] List" <pgsql-interfaces(at)postgresql(dot)org> |
Subject: | Re: Connecting - Need Help ! |
Date: | 2003-07-14 14:00:56 |
Message-ID: | 001a01c34a10$88f62230$1d8abfd5@darko |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-interfaces |
----- Original Message -----
From: "Peter Moscatt" <pgmoscatt(at)optushome(dot)com(dot)au>
To: "PostgreSQL [INTERFACES] List" <pgsql-interfaces(at)postgresql(dot)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 !
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2003-07-14 14:48:08 | Re: libpq:Find Table Name |
Previous Message | Darko Prenosil | 2003-07-14 12:30:20 | Re: libpq:Find Table Name |