RE: Postgres problem

Поиск
Список
Период
Сортировка
От Erny
Тема RE: Postgres problem
Дата
Msg-id 3b0980f4@news
обсуждение исходный текст
Ответ на Postgres problem  ("Prof. L M Patnaik" <lalit@micro.iisc.ernet.in>)
Список 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





В списке pgsql-interfaces по дате отправления:

Предыдущее
От: v j
Дата:
Сообщение: retrieval the history after psql command
Следующее
От: Alexey Nalbat
Дата:
Сообщение: Re: Subject: unbuffered results from libpq?