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

Re: Compiling "C" Functions

From: Ron Peterson <ron(dot)peterson(at)yellowbank(dot)com>
To: pgsql-sql(at)postgresql(dot)org
Subject: Re: Compiling "C" Functions
Date: 2000-12-28 14:36:57
Message-ID: 3A4B5009.9B09745D@yellowbank.com (view raw or flat)
Thread:
Lists: pgsql-sql
Tulio Oliveira wrote:
> 
> I appreciate any "C" Function complete samples, including de command
> line for
> the compiler.

I've attached a generic GNU make snippet for compiling .so files. 
Adjust to suite your tastes.  Like my math textbooks used to say
"writing the C code is trivial, and is left as an excercise for the
reader."  ;)

CC = /usr/bin/gcc
TARGET = debug
#TARGET = final
DFLAGS = -Wall -g
FFLAGS = -Wall -O2
SFLAGS = -fpic -shared
MYINCLUDES = -I/usr/local/include
-I/usr/local/src/postgresql/src/include -I/usr/local/postgresql/include
MYLIBS = -L/usr/local/lib -L/usr/local/postgresql/lib -lpq

ifeq ($(TARGET),final)
        MYCFLAGS = $(FFLAGS)
else
        MYCFLAGS = $(DFLAGS)
endif 

%.so:
        $(CC) $(MYCFLAGS) $(MYINCLUDES) $(MYLIBS) $(*F).c -c -o $(*F).o
        $(CC) $(SFLAGS) $(*F).o -o $(*F).so
	[ -d $(TARGET) ] || mkdir $(TARGET)
	mv $(*F).so $(TARGET)
        rm *.o

In response to

Responses

pgsql-sql by date

Next:From: Ron PetersonDate: 2000-12-28 14:45:32
Subject: Re: How to represent a tree-structure in a relational database
Previous:From: Ron PetersonDate: 2000-12-28 14:26:20
Subject: Re: How to represent a tree-structure in a relational database

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