Re: PG Extensions: Must be statically linked?

Поиск
Список
Период
Сортировка
От Craig A. James
Тема Re: PG Extensions: Must be statically linked?
Дата
Msg-id 440864BE.40509@modgraph-usa.com
обсуждение исходный текст
Ответ на Re: PG Extensions: Must be statically linked?  (Peter Eisentraut <peter_e@gmx.net>)
Ответы Re: PG Extensions: Must be statically linked?  (Martijn van Oosterhout <kleptog@svana.org>)
Re: PG Extensions: Must be statically linked?  (Tom Lane <tgl@sss.pgh.pa.us>)
Список 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
withoutstatic linking.  But the Postgres linker uses the C (not the C++) linker to resolve references, so it's not
findingthe C++ libraries.
 

My original question was misleading.  I said, "I have to link everything statically...", when in fact what should have
saidwas, "If I link statically, it works."  I now realize that I'm not linking everything statically, just the
OpenBableand 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
mangledname 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
optionfor Postgres use the C++ dynamic linker?  I don't mind statically linking OpenBabel, but it seems like a bad idea
toput 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




В списке pgsql-hackers по дате отправления:

Предыдущее
От: Andrew Dunstan
Дата:
Сообщение: Re: Initdb on Windows 2003
Следующее
От: "Luke Lonergan"
Дата:
Сообщение: Re: PostgreSQL Anniversary Summit, Call for