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.

---------------------------(end of broadcast)---------------------------
TIP 4: Have you searched our list archives?

               http://archives.postgresql.org/

Reply via email to