Prerequisites

Because an ecpg application is written in C, you will need a C compiler, the GNU make utility, and the ecpg preprocessor and library on your system before you can try the examples in this chapter.

The makefile for this chapter follows:

 1 INCLUDES = -I$(shell pg_config --includedir)
 2
 3 LIBPATH  = -L $(shell pg_config --libdir)
 4
 5 CFLAGS    += $(INCLUDES) -g
 6 LDFLAGS   += -g
 7 LDLIBS    += $(LIBPATH) -lecpg -lpq
 8 ECPGFLAGS += -c $(INCLUDES)
 9 ECPG       = ecpg
10
11 .SUFFIXES: .pgc
12
13 .pgc.c:
14         $(ECPG) $(ECPGFLAGS) $?
15
16 ALL  = client1a client1b client2a client2b client2c
17 ALL += client3a client3b client3c client3d client3e client3f
18 ALL += client4.pgc
19
20 all: $(ALL)
21
22 clean:
23         rm -f $(ALL) *~
24

The examples in this chapter ...

Get PostgreSQL, Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.