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 follow the normal PostgreSQL convention of naming ecpg source files with the extension .pgc. The makefile rules on lines 11 through 14 tell make that it can convert a .pgc file into a .c file by running the ecpg preprocessor.

Assuming that you have the prerequisites in place, let's start out by developing a simple client that will connect to a database using ecpg.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.222.197.35