Subject: Problem about LIBPQ

From: [email-masked] (Final Year Project)
Date: Fri, 12 Nov 93 11:45:50 +0800

Dear Sir/Madam,
I have gone through the ref.ps. But I can't find the part about
the compilation of C files. Can you tell me where it is?
My working directory is not the postgres directory. I want to ask
whether I have to change the path of the header files to be included
in other header files.
Also, in SAMPLE PROGRAM 1 on p.120 of ref.ps, why only libpq.h is 
included ? The function PQexec, PQsetdb are not found in libpq.h.
Is the program OK ? Is libpq.h the only header file to be included
when using the LIBPQ functions ?  Thanks.

Regards,
Martha Leung

---

From: [email-masked] (Paul M. Aoki)
Date: Fri, 12 Nov 93 01:00:33 -0800

general note for everyone: if you have something that you think
may be a FAQ (frequently-asked question), send it to 
post_questions@postgres instead of postgres@postgres.  the
latter is the general mailing list of all users..

> the compilation of C files. Can you tell me where it is?

i usually just tell people to use the same -I directives that 
they would use to build dynamically-loaded functions.  this
discussion is in the user manual and the "define function"
man page.  in fact, it's pretty much the only discussion of
compiling *anything* in the whole manual right now (except in
the large object section), so people usually just stumble across 
it :-P  (most people can figure out how to link against libpq.a
so -L and -l directives have not been a problem. :-)  if you 
look in the source tree, that's also how we build the frontend 
apps that come with postgres.

at the last minute, marc decided that this was a crufty way
to do things (since you have to leave the source tree around).
now, in theory, the include/ and lib/ directories should hold 
everything you need for building libpq apps.  however, this is
essentially an undocumented feature and, in point of fact,
what's in include/ is not complete (this is noted in the 
postgres-setup file, which requests feedback on this matter).

the short answer is, if "..." is where postgres is installed,
you need something like
	cc <stuff> -I.../include -L.../lib <more stuff> -lpq
however, this sometimes gives you "can't find <blah>.h", in 
which case you need to stick in the -I directives from "define 
function" anyway.

if you have feedback about missing stuff in include/, send mail 
to bug-postgres@postgres.

(the documentation has been in pretty bad shape for a long time,
and is undergoing a general overhaul..)

> whether I have to change the path of the header files to be included

use the right -I directives and /bin/cc will do the rest. :-)
however, as mentioned, the right -I directives depend on where
your sysadmin installed stuff..

> when using the LIBPQ functions ?  Thanks.

"tmp/libpq-fe.h" is also often useful and includes libpq.h.
--
  Paul M. Aoki  |  CS Div., Dept. of EECS, UCB  |  [email-masked]
                |  Berkeley, CA 94720           |  ...!uunet!ucbvax!aoki