[postgis-users] Linking to the PostGIS library
Nathaniel
naptrel at yahoo.co.uk
Thu Nov 16 07:26:41 PST 2006
On 16 Nov 2006, at 09:10, strk at refractions.net wrote:
> Missing -llwgeom ?
> Also -rpath might be useful as liblwgeom is likely *not* in your
> default path.
> Check with 'ldd' (or whatever apple changed it to)
Thanks strk for the reply. I used your suggestions to fuel more
internet searches, and it seems it's not that simple on the mac
(anyone surprised?) In case someone in the future has similar
problems and stumbles upon this thread, here's what I've found so far:
On the mac, postgres needs what Apple calls a "bundle" (aka "loadable
module"), which is a form of dynamic library. This is a tad different
from your standard unixian shared lib. For one, bundles seem to have
a significant limitation: you can't link against them (at least
according to <http://fink.sourceforge.net/doc/porting/shared.php> )!
This explains why I've struggled for hours to build my
library...achem, I mean bundle....against the PostGIS liblwgeom.so
bundle.
You can build proper, dynamic shared libs on the mac (using -
dynamiclib flag to gcc). The generic Postgres module makefile
(Makefile.shlib), as used by PostGIS, even teasingly comes with a
flag (DLTYPE), that if set to "library", looks as though it should
build one of these. So I thought, if I could build PostGIS as a
proper dynamic, shared library rather than a bundle, I could link my
code against it. (I didn't care if I had to have both liblwgeom.so
and liblwgeom.dylib sitting in /usr/local/pgsql/lib/, the former for
function calls to the postgis module, the latter for calls to mine).
Permitting myself to hack only a handful of lines I couldn't get
PostGIS to successfully build a ".dylib" that I could build against.
Changing lots of build or source code would make upgrading PostGIS
prohibitively time-consuming.
But I did find a simple, if less-than-satisfactory, one line
solution: merge my library (compiled into myfoo.o, say) into the
PostGIS build!
In lwgeom/Makefile:
OBJS=$(SA_OBJS) liblwgeom.o [...] long_xact.o myfoo.o
Then, change my SQL function definitions to point to "liblwgeom"
rather than "libmyfoo" and I'm off. Thanks again
Send instant messages to your online friends http://uk.messenger.yahoo.com
More information about the postgis-users
mailing list