Thread: libpgeasy.h

libpgeasy.h

From
"Kancha ."
Date:
I'm using RH 7.2 with the default postgresql that
comes along (ver 7.1)

I'm trying to write a program usign libpgeasy. I wrote
a sample code just to get the feel and got following
error. I don't what it means. The program won't
compile with gcc.

-- code --#include <stdio.h>
#include <pgsql/libpq-fe.h>
#include <pgsql/libpgeasy.h>

int main(){
        char loginName[20];
        char sql[256];

        connectdb("hostaddr=192.168.1.4 dbname=mydb
user=user password=password");
        sprintf(sql, "select loginname from
cst_customer");
        doquery(sql);

        while(fetch(loginName) != END_OF_TUPLES)
                printf("%s\n", loginName);

        disconnectdb();

        return 0;
}


-- error produced by gcc --

/tmp/cc3OLzfr.o: In function `main':
/tmp/cc3OLzfr.o(.text+0x12): undefined reference to
`connectdb'
/tmp/cc3OLzfr.o(.text+0x3b): undefined reference to
`doquery'
/tmp/cc3OLzfr.o(.text+0x4c): undefined reference to
`fetch'
/tmp/cc3OLzfr.o(.text+0x75): undefined reference to
`disconnectdb'
collect2: ld returned 1 exit status


__________________________________________________
Do You Yahoo!?
Yahoo! Tax Center - online filing with TurboTax
http://taxes.yahoo.com/

Re: libpgeasy.h

From
Oliver Elphick
Date:
On Sat, 2002-04-06 at 10:24, Kancha . wrote:
> I'm using RH 7.2 with the default postgresql that
> comes along (ver 7.1)
>
> I'm trying to write a program usign libpgeasy. I wrote
> a sample code just to get the feel and got following
> error. I don't what it means. The program won't
> compile with gcc.
...
> /tmp/cc3OLzfr.o: In function `main':
> /tmp/cc3OLzfr.o(.text+0x12): undefined reference to
> `connectdb'
> /tmp/cc3OLzfr.o(.text+0x3b): undefined reference to
> `doquery'
> /tmp/cc3OLzfr.o(.text+0x4c): undefined reference to
> `fetch'
> /tmp/cc3OLzfr.o(.text+0x75): undefined reference to
> `disconnectdb'
> collect2: ld returned 1 exit status

The problem is that the linker is not finding the libpgeasy library.

Your compile command should include
   -L/path/to/your/libpgeasy.so -lpgeasy

--
Oliver Elphick                                Oliver.Elphick@lfix.co.uk
Isle of Wight                              http://www.lfix.co.uk/oliver
GPG: 1024D/3E1D0C1C: CA12 09E0 E8D5 8870 5839  932A 614D 4C34 3E1D 0C1C

     "A gentle answer turns away wrath, but a harsh word
      stirs up anger."        Proverbs 15:1

Attachment