From: Erny <aerd@mx3.redestb.es>
To: pgsql-interfaces@postgresql.org
Subject: RE: Postgres problem
Date: Mon, 21 May 2001 22:41:30 +0200
Message-ID: <3b0980f4@news> (raw)
References: <Pine.SGI.4.10.10104191831150.839-100000@micro.iisc.ernet.in>
> 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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-interfaces@postgresql.org
Cc: aerd@mx3.redestb.es
Subject: RE: Postgres problem
In-Reply-To: <3b0980f4@news>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
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