Thread: Has anybody compiled .c file generated from .pgc file

Has anybody compiled .c file generated from .pgc file

From
"Chandra Sekhar . K"
Date:
Hi,

      I have been trying to run a sample  code for postgreSQL database.
I just want to create a database and do simple insertion and extraction
of the inserted data. I have created .pgc file and am able to generate
 .c file using ecpg but I am stuck with gcc , not able to create the
 binary from .c file.

     I am getting the following error, has anybody have experienced
similar problem before.

Thanks,
Chandra

#gcc -I /usr/local/pgsql/include/ -L/usr/local/pgsql/lib -lecpg -lpq sam1.c
/cygdrive/c/TEMP/ccqnr98f.o(.text+0x266):sam1.c: undefined reference to
`ECPGconnect'
/cygdrive/c/TEMP/ccqnr98f.o(.text+0x26f):sam1.c: undefined reference to `sqlca'
/cygdrive/c/TEMP/ccqnr98f.o(.text+0x277):sam1.c: undefined reference to
`sqlprint'
/cygdrive/c/TEMP/ccqnr98f.o(.text+0x28c):sam1.c: undefined reference to
`ECPGdo'
/cygdrive/c/TEMP/ccqnr98f.o(.text+0x295):sam1.c: undefined reference to `sqlca'
/cygdrive/c/TEMP/ccqnr98f.o(.text+0x29d):sam1.c: undefined reference to
`sqlprint'
/cygdrive/c/TEMP/ccqnr98f.o(.text+0x2ae):sam1.c: undefined reference to
`ECPGtrans'
/cygdrive/c/TEMP/ccqnr98f.o(.text+0x2b7):sam1.c: undefined reference to `sqlca'
/cygdrive/c/TEMP/ccqnr98f.o(.text+0x2bf):sam1.c: undefined reference to
`sqlprint'
/cygdrive/c/TEMP/ccqnr98f.o(.text+0x2d4):sam1.c: undefined reference to
`ECPGdo'
/cygdrive/c/TEMP/ccqnr98f.o(.text+0x2dd):sam1.c: undefined reference to `sqlca'
/cygdrive/c/TEMP/ccqnr98f.o(.text+0x2e5):sam1.c: undefined reference to
`sqlprint'
/cygdrive/c/TEMP/ccqnr98f.o(.text+0x2fa):sam1.c: undefined reference to
`ECPGdo'
/cygdrive/c/TEMP/ccqnr98f.o(.text+0x303):sam1.c: undefined reference to `sqlca'
/cygdrive/c/TEMP/ccqnr98f.o(.text+0x30b):sam1.c: undefined reference to
`sqlprint'
/cygdrive/c/TEMP/ccqnr98f.o(.text+0x320):sam1.c: undefined reference to
`ECPGdo'
/cygdrive/c/TEMP/ccqnr98f.o(.text+0x329):sam1.c: undefined reference to `sqlca'
/cygdrive/c/TEMP/ccqnr98f.o(.text+0x331):sam1.c: undefined reference to
`sqlprint'
/cygdrive/c/TEMP/ccqnr98f.o(.text+0x346):sam1.c: undefined reference to
`ECPGdo'
/cygdrive/c/TEMP/ccqnr98f.o(.text+0x34f):sam1.c: undefined reference to `sqlca'
/cygdrive/c/TEMP/ccqnr98f.o(.text+0x357):sam1.c: undefined reference to
`sqlprint'
/cygdrive/c/TEMP/ccqnr98f.o(.text+0x36c):sam1.c: undefined reference to
`ECPGdo'
/cygdrive/c/TEMP/ccqnr98f.o(.text+0x375):sam1.c: undefined reference to `sqlca'
/cygdrive/c/TEMP/ccqnr98f.o(.text+0x37d):sam1.c: undefined reference to
`sqlprint'
/cygdrive/c/TEMP/ccqnr98f.o(.text+0x38e):sam1.c: undefined reference to
`ECPGtrans'
/cygdrive/c/TEMP/ccqnr98f.o(.text+0x397):sam1.c: undefined reference to `sqlca'
/cygdrive/c/TEMP/ccqnr98f.o(.text+0x39f):sam1.c: undefined reference to
`sqlprint'
collect2: ld returned 1 exit status


RE: Has anybody compiled .c file generated from .pgc file

From
"Riebs, Andy"
Date:
> I have been trying to run a sample code for postgreSQL
> database.  I just want to create a database and do simple
> insertion and extraction of the inserted data. I have
> created .pgc file and am able to generate .c file using
> ecpg but I am stuck with gcc , not able to create the
> binary from .c file.

Use a Makefile to specify the locations of the libraries,
such as...

-----snip-----
SRCDIR=../postgres/src
CFLAGS+=-I$(SRCDIR)/include
CFLAGS+=-I$(SRCDIR)/interfaces/libpq
CFLAGS+=-I$(SRCDIR)/interfaces/ecpg/include
LIBPQDIR=$(SRCDIR)/interfaces/libpq
LIBECPGDIR=$(SRCDIR)/interfaces/ecpg/lib
LDFLAGS+=-L$(LIBPQDIR) -lpq
LDFLAGS+=-L$(LIBECPGDIR) -lecpg
LDFLAGS+=-g
%.c : %.pgc
    ecpg -t -o $@ $<
-----snip-----

/andy

---
Andy Riebs, andy.riebs@compaq.com    Alpha Technology Solutions Group
978-506-6628, fax 978-506-6524       Compaq Computer Corporation
(h) andy@freckles.mv.com            <http://www.linuxalpha.compaq.com>