Skip site navigation (1) Skip section navigation (2)

Re: Linking ECPG files to a C program

From: Antonio Sergio de Mello e Souza <asergioz(at)bol(dot)com(dot)br>
To: hopeye(at)cfl(dot)rr(dot)com
Cc: pgsql-interfaces(at)postgresql(dot)org
Subject: Re: Linking ECPG files to a C program
Date: 2002-03-06 13:39:42
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-interfaces
  Jim Parker wrote:

>Should I create a library to hold the ECPG routines ?  
It is not necessary.

>Does anyone have any example code/Makefile I can look at ?
This is an example similar to the makefile that I use:

EC       = ecpg
CC       = gcc
INCPG    = /usr/local/pgsql/include   # Path for postgresql includes.
INCAPP   = ../h                       # Path for application-specific 
INCSQL   = ../h                       # Path for host variables 
declarations header.
LIBPG    = /usr/local/pgsql/lib       # Path for ecpg libraries.
LIBSPG   = -lecpg -lpq                # Ecpg libraries.
CFLAGS   = -Wall -g -c

# I use the suffix '.ec' for ecpg source files instead of '.pgc'.

%.c :
    $(EC) -t -I $(INCSQL) -o $@ $<

%.o : %.c
    $(CC) $(CFLAGS) -I $(INCPG) -I $(INCAPP) -o $@ $<

% : %.o ;

.PHONY: all util clean

all: util program1 program2

util: util1.o util2.o util3.o

program1: program1.o util1.o util2.o
    $(CC) -o $@ $^ -L $(LIBPG) $(LIBSPG)

program2: program2.o util2.o util3.o
    $(CC) -o $@ $^ -L $(LIBPG) $(LIBSPG)

    -rm -f *.o core


Antonio Sergio

In response to


pgsql-interfaces by date

Next:From: Jorge_MendezDate: 2002-03-06 15:58:10
Previous:From: Jose Luis LGDate: 2002-03-06 09:35:19
Subject: Re: Error passing parameter to functions

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group