Re: PG Extensions: Must be statically linked?
От | Martijn van Oosterhout |
---|---|
Тема | Re: PG Extensions: Must be statically linked? |
Дата | |
Msg-id | 20060303160222.GC17615@svana.org обсуждение исходный текст |
Ответ на | Re: PG Extensions: Must be statically linked? ("Craig A. James" <cjames@modgraph-usa.com>) |
Список | pgsql-hackers |
On Fri, Mar 03, 2006 at 07:46:06AM -0800, Craig A. James wrote: > 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. <snip> > 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. There are a number of ways to indicate which extra libraries to load, but by far the easiest is by specifying them on the link line. Your problem is that when creating a shared library, you are not required to make sure all your external symbols are defined somewhere. You didn't post your compile/link line but if you're using C++ you probably need to use g++ for the linking to include the special C++ libraries. One way to find out what's going on is using readelf: $ readelf -a /bin/bash |grep NEEDED0x00000001 (NEEDED) Shared library: [libncurses.so.5]0x00000001 (NEEDED) Shared library: [libdl.so.2]0x00000001 (NEEDED) Shared library: [libc.so.6] These are the libraries that will be loaded when someone tries to load your shared lib (the above works on any ELF object). The easiest is to specify "--no-undefined" on the link line so the linker checks up front you won't get undefined symbols at run time. Remember it's -Wl,--no-undefined if invoking from gcc/g++. Hope this helps, -- Martijn van Oosterhout <kleptog@svana.org> http://svana.org/kleptog/ > Patent. n. Genius is 5% inspiration and 95% perspiration. A patent is a > tool for doing 5% of the work and then sitting around waiting for someone > else to do the other 95% so you can sue them.
В списке pgsql-hackers по дате отправления: