[postgis-devel] How to create user-defined C function using a postgis C function
Peter Tolkewitz
peter.tolkewitz at gmx.de
Sun Nov 10 11:54:18 PST 2013
Hi there,
what is the appropriate way to create a new user-defined C function using a postgis C function and define it as new Postgres function using CREATE FUNCTION .. LANGUAGE C?
According to http://www.postgresql.org/docs/9.1/static/xfunc-c.html, I sucessfully compiled test.c (see below) under linux with...
> cc -I/usr/include/pgsql/server -fpic -c test.c
> cc -shared -o test.so test.o
...to a shared library called "test.so" file but...
> CREATE FUNCTION test(geometry,box2d) RETURNS geometry AS '/path/to/test.so', 'test' LANGUAGE C STRICT;
...complains with undefined symbol "lwgeom_clone_deep", although LWGEOM and GBOX seems to be known at the same time.
It seems that test.so does not know about the postgis library, how can that be achieved?
Thank you for any hints, Peter
-------- start test.c --------
#include "liblwgeom.h"
#include "postgres.h"
#include "fmgr.h"
PG_MODULE_MAGIC;
LWGEOM* test(LWGEOM *in, GBOX *bounds) {
// just a test
return lwgeom_clone_deep(in); // defined in liblwgeom.h
}
-------- end test.c --------
More information about the postgis-devel
mailing list