From: | "Craig A(dot) James" <cjames(at)modgraph-usa(dot)com> |
---|---|
To: | pgsql-hackers(at)postgresql(dot)org |
Subject: | Re: PG Extensions: Must be statically linked? |
Date: | 2006-03-03 15:46:06 |
Message-ID: | 440864BE.40509@modgraph-usa.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
Peter Eisentraut wrote:
>>Unfortunately, we're also using a second library (OpenBabel) that is
>>written in C++. A good portion of the code I've written is a wrapper
>>layer that hides the C++ objects and presents a simple C wrapper that
>>works for Postgres.
>
> I suggest if you want to get any concrete advice out of this, post us
> the commands that you execute and the error messages that you get.
Thanks for your answers -- see below.
Based on Peter's and Tom's replies regarding C++, I think you've answered my question: I should be able to do this without static linking. But the Postgres linker uses the C (not the C++) linker to resolve references, so it's not finding the C++ libraries.
My original question was misleading. I said, "I have to link everything statically...", when in fact what should have said was, "If I link statically, it works." I now realize that I'm not linking everything statically, just the OpenBable and C++ libraries, and in fact Postgres is finding the other libraries I need, like libz, libm, and so forth.
Here's what happens when I don't statically link the C++ libraries or the OpenBabel libraries:
[root]# cp libmyfuncs.so /usr/local/pgsql/lib
$ psql -d myfuncs -U postgres
Welcome to psql 8.0.3, the PostgreSQL interactive terminal.
...
myfuncs=# CREATE FUNCTION myfunc(text, text) RETURNS boolean
myfuncs-# AS '/usr/local/pgsql/lib/libmyfuncs.so', 'myfunc'
myfuncs-# LANGUAGE 'C' STRICT;
ERROR: could not load library "/usr/local/pgsql/lib/libmyfuncs.so": /usr/local/pgsql/lib/libmyfuncs.so: undefined symbol: _ZdlPv
That symbol is obviously a C++ mangled name, so it's not finding the C++ library, and the fact that it prints the mangled name suggests that it's a C linker, not a C++ linker.
So now my question is: Can I somehow add other directories/libraries to those that Postgres uses? Or is there an option for Postgres use the C++ dynamic linker? I don't mind statically linking OpenBabel, but it seems like a bad idea to put the specific version- and system-dependent location of libstdc++.a into my makefiles.
(Am I the only guy in the world who has to use a C++ library as part of a Postgres function?)
Thanks,
Craig
From | Date | Subject | |
---|---|---|---|
Next Message | Luke Lonergan | 2006-03-03 15:50:51 | Re: PostgreSQL Anniversary Summit, Call for |
Previous Message | Andrew Dunstan | 2006-03-03 15:41:12 | Re: Initdb on Windows 2003 |