<html><head></head><body><div style="font-family: Verdana;font-size: 12.0px;"><div>Hi there,<br/>
<br/>
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?<br/>
<br/>
According to <a href="http://www.postgresql.org/docs/9.1/static/xfunc-c.html" target="_blank">http://www.postgresql.org/docs/9.1/static/xfunc-c.html</a>, I sucessfully compiled test.c (see below) under linux with...<br/>
<br/>
<br/>
> cc -I/usr/include/pgsql/server -fpic -c test.c<br/>
> cc -shared -o test.so test.o<br/>
<br/>
...to a shared library called "test.so" file but...<br/>
<br/>
> CREATE FUNCTION test(geometry,box2d) RETURNS geometry AS '/path/to/test.so', 'test' LANGUAGE C STRICT;<br/>
<br/>
...complains with undefined symbol "lwgeom_clone_deep", although LWGEOM and GBOX seems to be known at the same time.<br/>
<br/>
It seems that test.so does not know about the postgis library, how can that be achieved?<br/>
<br/>
<br/>
Thank you for any hints, Peter<br/>
<br/>
<br/>
-------- start test.c --------<br/>
<br/>
#include "liblwgeom.h"<br/>
#include "postgres.h"<br/>
#include "fmgr.h"<br/>
<br/>
PG_MODULE_MAGIC;<br/>
<br/>
LWGEOM* test(LWGEOM *in, GBOX *bounds) {<br/>
// just a test<br/>
return lwgeom_clone_deep(in); // defined in liblwgeom.h<br/>
}<br/>
<br/>
-------- end test.c --------</div></div></body></html>