Return-Path: pg_adm@postgres.berkeley.edu
Received: by postgres.Berkeley.EDU (5.61/1.29)
	id AA10628; Thu, 31 Dec 92 12:02:09 -0800
Date: Thu, 31 Dec 92 12:02:09 -0800
From: Phil Shen <philshen@cs.washington.edu>
Subject: C compiling problem...
To: postgres@postgres.berkeley.edu
Sender: pg_adm@postgres.berkeley.edu
To: postgres@postgres.berkeley.edu
Cc: Philip Shen <philshen@cs.washington.edu>
Message-Id: <Pine.3.05.9212311105.B23664-b100000@wolf.cs.washington.edu>
Mime-Version: 1.0
Content-Type: TEXT/PLAIN; CHARSET=US-ASCII


Hi,

I'm a beginner with the Postgres system, so please bear with me...

I'm running on SunOS ver. 4.1.2.

I've run into a problem with compiling C code into executables to access
Postgres database files.  The problem is, I think I can compile to get .o
files, but not .out* executable files.  I tried to find help in the
reference manual about compiling, but all it says is to use the cc
-IPOSTGRESHOME -IPORTNAME -something about the machine, etc. to compile. 
I have set the environment variables POSTGRESHOME and PORTNAME to
~postgres and sunos4 respectively.

When I try to use "ld" to link the object code, it can't find the
references to PQexe, etc. in the include files.

Can you tell me specifically how to compile the following file on Lillith
to get an executable?  (I realize that the code may not be correct either
but I need to know how to compile the C code first...)


#include <stdio.h>
#include <tmp/libpq-fe.h>
#include <tmp/postgres.h>

main()
{
   int4 Id;

   PQsetdb("db2");
   PQexec("begin");
   printf("\nEnter an id: ");
   scanf("%d",&Id);
   PQexec("retrieve (KBTERMS.name) where (KBTERMS.id =%ld)",Id);
   PQfinish();
 }


Thanks very much for your time,
Phil




