[postgis-users] Linking to the PostGIS library

Nathaniel naptrel at yahoo.co.uk
Wed Nov 15 02:57:50 PST 2006


Dear all,

I'm writing some C-functions to plug into postgres. Some of these  
functions need to manipulate PostGIS geometries, so I'm trying to  
link my code against the postgis library liblwgeom.so to make use of  
the postgis functions that untangle geometries (e.g.  
lwpoint_deserialize, lwpoint_getPointXX_p etc)

Header files are included, so my code compiles cleanly, but loading  
the functions into postgres brings up "Symbol not found:  
_lwgeom_deserialize" errors as postgres tries to find symbols defined  
in my code and doesn't know to look in the postgis shared library to  
find them.

I'm running macos10.4, postgres 8.1.4, postgis 1.1.6.

Presently, my "build script" is taken straight out the postgres manual:

     cc -I/usr/local/pgsql/include/server/ -I./postgis-1.1.6/lwgeom/ - 
c foo.c

     cc -bundle -flat_namespace -undefined suppress -o libfoo.so foo.o;

The -I's in the first line help the compiler find the postgres/ 
postgis headers respectively.

What extra/different compiler/linker flags do I need to squeeze some  
of that postgis magic into my library? Remember it's MacOSX--it's  
unix Jim, but not as we know it--so although gcc compiler flags are  
all a bit Appleified, things may work as per linux? I'm experienced  
at writing C, but very inexperienced at building/linking (yes, it's a  
bit odd) so hopefully this is simple newbie ignorance. Please help!

Nath
Send instant messages to your online friends http://uk.messenger.yahoo.com 



More information about the postgis-users mailing list