[lug] C extensions of PostgreSQL
rm at fabula.de
rm at fabula.de
Thu Aug 7 00:41:40 MDT 2003
On Wed, Aug 06, 2003 at 02:52:14PM -0600, B Giles wrote:
> >I just want to know what lib to link...the sample code I have is fine, it
> >is coded and complete...what I need is for a lib that implements
> >functionality for palloc (those symbols missing are because palloc
> >references them).
>
> I keep thinking that you're missing some registration functions, but maybe
> that's only with user-defined types or people who need to initialize an
> external library. E.g., I had to initialize the OpenSSL library and
> configure it to use palloc instead of the default memory allocation
> routines.
Nope, no need to do that for a function. That pretty much get's incorporated
into the backend by dlopening the (.so) file and finding the corresponding
c function by name.
AFAIK there is no special library one has to link against -- pmalloc
is provided by the host application (so including the appropriate
headers should be enough). Of course the compiler/linker has to know that
it is supposed to build shared code (-fPIC and -shared should do that).
# -----x snip x---------------------------------------------------------
PREFIX=/usr/local
# use pg_config to query installation locations
PGCONFIG=pg_config
CC = gcc
CFLAGS = -I `$(PGCONFIG) --includedir` \
-I `$(PGCONFIG) --includedir-server` \
-fpic -shared
LIBS = -L `$(PGCONFIG) --libdir`
WARNINGS = -Wall -Wmissing-prototypes
INSTDIR = `$(PGCONFIG) --pkglibdir`
SRC=facts.c
install: dso
install -D -o postgres facts.so $(INSTDIR)/facts.so
dso: facts.so
facts.so: facts.c facts.h Makefile
$(CC) $(WARNINGS) $(CFLAGS) $(LIBS) -o facts.so $(SRC)
#-----------x snip x-------------------------------------------
hth Ralf Mattes
More information about the LUG
mailing list