RE: Postgres problem

From: "Erny" <aerd(at)mx3(dot)redestb(dot)es>
To: pgsql-interfaces(at)postgresql(dot)org
Subject: RE: Postgres problem
Date: 2001-05-21 20:41:30
Message-ID: 3b0980f4@news
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-interfaces

> 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

In response to

Browse pgsql-interfaces by date

  From Date Subject
Next Message Erny 2001-05-21 20:57:23 Python pg module and loimport
Previous Message Erny 2001-05-21 20:27:49 RE: Python as a procedural language