Thread: include all the postgres libraries (C)

include all the postgres libraries (C)

From
"Janek Sendrowski"
Date:
Hi,
 
I like to try some things with C and I need certain postgres libraries for it.
This time, I'm including postgres.h for example, but postgres.h doesn't include it's files.
How do I include the whole tree, or is there a certain directory I can use.
I just want to compile and run the files for first.
 
Janek Sendrowski


Re: include all the postgres libraries (C)

From
Kevin Grittner
Date:
Janek Sendrowski <janek12@web.de> wrote:

> I like to try some things with C and I need certain postgres libraries for it.
> This time, I'm including postgres.h for example, but postgres.h doesn't
> include it's files.
> How do I include the whole tree, or is there a certain directory I can use.
> I just want to compile and run the files for first.

You might want to look at the directories under the contrib
directory.  It's not clear whether you are trying to write a client
application or something that will run on the backend, but you can
find examples of both in contrib.

Depending on what you are trying to do, this section of the docs
might help:

http://www.postgresql.org/docs/9.2/interactive/server-programming.html

--
Kevin Grittner
EDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company


Re: include all the postgres libraries (C)

From
Alvaro Herrera
Date:
Janek Sendrowski wrote:
> Hi,
>  
> I like to try some things with C and I need certain postgres libraries for it.
> This time, I'm including postgres.h for example, but postgres.h doesn't include it's files.
> How do I include the whole tree, or is there a certain directory I can use.
> I just want to compile and run the files for first.

You don't ever include all the header files we ship; most contain stuff
you don't care about.  Just list the ones you really need in separate
#include lines.

--
Álvaro Herrera                http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Training & Services


Re: include all the postgres libraries (C)

From
"Janek Sendrowski"
Date:
I think PGXS is, what I've been looking for.

 

My Makefile looks like this:


 PROGRAM = test
DATA = test.c
 PG_CONFIG = pg_config
PGXS := $(shell $(PG_CONFIG) --pgxs)
include $(PGXS)

 


The file test.c only includes the postgres.h, but I get this error, when compiling:

/usr/bin/ld: cannot find -lxslt
/usr/bin/ld: cannot find -lxml2
/usr/bin/ld: cannot find -lpam
/usr/bin/ld: cannot find -ledit
collect2: ld returned 1 exit status
make: *** [test] Error 1

 

Does anyone have an idea?

 

Janek Sendrowski