Using C API - Mailing list pgsql-general

From pgsql.gen@tuxbeagle.com
Subject Using C API
Date
Msg-id 999334.968841191975923531.JavaMail.servlet@perfora
Whole thread Raw
Responses Re: Using C API  (Lars Heidieker <lars@heidieker.de>)
Re: Using C API  (Tom Lane <tgl@sss.pgh.pa.us>)
Re: Using C API  (Greg Smith <gsmith@gregsmith.com>)
List 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.

pgsql-general by date:

Previous
From: "Andrus"
Date:
Subject: Re: reporting tools
Next
From: "Greg Wickham"
Date:
Subject: PLPGSQL 'SET SESSION ROLE' problems ..