Using C API

From: pgsql(dot)gen(at)tuxbeagle(dot)com
To: <pgsql-general(at)postgresql(dot)org>
Subject: Using C API
Date: 2007-10-10 00:25:23
Message-ID: 999334.968841191975923531.JavaMail.servlet@perfora
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

I was trying this example program out of a well known postgresql book and keep getting errors whenever I try to compile.

Error messages ##make client1

cc -g -I /usr/include -I /usr/include/pgsql -I /usr/include/pgsql/server -c -o client1.o client1.c
cc -g client1.o -L /usr/lib -L /usr/lib/pgsql -o client1
client1.o: In function `main':
/root/PROGRAMMING/C_API/client1.c:10: undefined reference to `PQconnectdb'
/root/PROGRAMMING/C_API/client1.c:11: undefined reference to `PQfinish'
collect2: ld returned 1 exit status
make: *** [client1] Error 1
---------------------------------------------------------

--------------------------------------------------
/*
** File: client1.c
*/

#include "libpq-fe.h"

int main( void )
{
PGconn * connection;
connection = PQconnectdb( "dbname='MyTestDB'" );
## I tried the above line with
## connection = PQconnectdb( "" );
## as per the book
PQfinish( connection ) ;
return( 0 );
}
-----------------------------------------------------
## File: Makefile
##
## Rules to create libpq sample applications
##

CPPFLAGS += -I /usr/include -I /usr/include/pgsql -I /usr/include/pgsql/server
CFLAGS += -g
LDFLAGS += -g
LDLIBS += -L /usr/lib -L /usr/lib/pgsql
client1: client1.o
-------------------------------------------------

following are the rpms I have installed on a RHEL5 system.
postgresql-plperl-8.2.4-1PGDG
postgresql-contrib-8.2.4-1PGDG
postgresql-python-8.1.9-1.el5
postgresql-docs-8.2.4-1PGDG
postgresql-server-8.2.4-1PGDG
postgresql-devel-8.2.4-1PGDG
postgresql-8.2.4-1PGDG
postgresql-plpython-8.2.4-1PGDG
compat-postgresql-libs-4-2PGDG.rhel4
postgresql-libs-8.2.4-1PGDG
postgresql-pltcl-8.2.4-1PGDG

Yes I see the compat one and will install rhel5 if I find one.

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Gregory Stark 2007-10-10 00:32:12 Re: Generating subtotal reports direct from SQL
Previous Message Dmitry Koterov 2007-10-09 23:01:58 How to speedup intarray aggregate function?