7.2.1 failure to complie C programs

From: rexrecio(at)yahoo(dot)com (Rex Recio)
To: pgsql-interfaces(at)postgresql(dot)org
Subject: 7.2.1 failure to complie C programs
Date: 2002-09-02 03:37:43
Message-ID: f06e5984.0209011937.2cd2052a@posting.google.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-interfaces

I have been trying to compile my first C program on PostgreSQL 7.1.2.
Here is my source code:

/*filename is hello.c*/
#include <stdio.h>
#include "libpq-fe.h"

int main (int argc, char *argv[])
{
PGConn *masterConn;
printf("Hello World!\n");
masterConn = PQconnectdb("hostaddr=192.168.0.23 dbname=masterdb
user=postgres
password=postgres");
return 1;
}

I tried compliling it using gcc -c hello.c but it gives me the
following error:
hello.c: In function `main':
hello.c:6: `PGConn' undeclared (first use in this function)
hello.c:6: (Each undeclared identifier is reported only once
hello.c:6: for each function it appears in.)
hello.c:6: `masterConn' undeclared (first use in this function)

The include file for POstgreSQL is already located at the
/usr/include. Nevertheless I also tried specifying it in the
complier. I tried compiling using:
gcc -c hello.c -I/usr/include
gcc -c hello.c -I/usr/include/pgsql

I got the same error.

I'm using RedHat 7.3 and the default Postgres installation that comes
with it, 7.2.1. I noticed that there is an 'undeclared error' for
PGConn but not for 'PQConnectdb'. I examnined the header file and
true enough there is no declaration for PGConn.

Is there anybody out there who had the same experience and was able to
fix it? Please help.

Responses

Browse pgsql-interfaces by date

  From Date Subject
Next Message Gerhard Hintermayer 2002-09-02 08:45:38 libpgtcl: pq_recvbuf: unexpected EOF on client connection
Previous Message Marc G. Fournier 2002-09-01 00:50:46 Re: [ODBC] [HACKERS] ODBC Driver moved to GBorg ...