> Hello:
Hi,
>
> I am having problem interfacing the postgres database with the
> frontend(libpq),i.e using C.Database runs fine.
>
> PROBLEMS ARE:
> 1)When compiling the C-program given in the
> example for connecting the database to the
> frontend using
> $gcc -I /home/guest/pgsql/include test.c
>
> output:
> /tmp/ccwWFbHo.o:In function 'exit_nicely':
> /tmp/ccwWFbHo.o(.text+0x8):undefined referance to 'PQfinish'
>
> /tmp/ccwWFbHo.o:In function 'main':
> /tmp/ccwWFbHo.o(.text+0x66):undefined referance to
> 'PQsetdblogin'
>
> /tmp/ccwWFbHo.o(.text+0x66):undefined referance to 'PQstatus'
I had the same problem. You have to include -lq on the command line.
Futhermore, I had to put it on the end of the line, because the compiler
collects unknown symbols first and then resolves it with the -l library
switch. So I made a little Makefile like this one:
#Little Makefile for making whatever source file directly to an executable.
override CFLAGS += -I/usr/include/postgresql
% : %.c $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $< -lpq
% : %.c++ g++ $(CFLAGS) $(LDFLAGS) -o $@ $< -lpq++
#end
Erny