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