dynamic library loading, missing symbols

Ames Andreas Andreas.Ames at comergo.com
Wed Jan 10 11:04:27 CET 2007


Some random notes below ...

> -----Original Message-----
> From: python-list-bounces+andreas.ames=comergo.com at python.org 
> [mailto:python-list-bounces+andreas.ames=comergo.com at python.or
> g] On Behalf Of dfj225 at gmail.com
> Sent: Wednesday, January 10, 2007 1:26 AM
> Subject: dynamic library loading, missing symbols
> 
> The reason for the complication is that I don't have control over how
> the library does dlopen() or how the code that calls dlopen was
> compiled. I am, however, able to control the build process for the
> Boost.Python wrapper and the original C++ code that the Boost.Python
> wraps. I've tried as many linker tricks as I can think of to get this
> to work. Both the boost wrapper and the C++ code that it wraps are
> built using --export-dynamic.

* Make sure the exported symbols are marked "extern C"

* Otherwise (you export C++ symbols), make sure the exporting component uses *exactly* the same compiler (version, ABI-influencing flags and all) as the importing component.

* IMHO, C++ .sos are principally painful and almost unbearable, if you have (non-source) third party components involved.

* Use nm to find the exact names of the exported and imported symbols (as already suggested).

> 
> Is there a way to set at runtime what directories or libraries the
> linker should search for these symbols? I have set LD_LIBRARY_PATH
> correctly, but that didn't seem to affect anything.
> 
> For reference, I am running on Gentoo linux 2.6.11.12 with gcc 3.4.4
> 
> I'm interested in any ideas that might help, but the ideal one should
> work on any *nix system and not just linux.

* You might read http://people.redhat.com/drepper/dsohowto.pdf, which I found very useful.  There are ways described, how to control the way, the dynamic loader resolves symbols, all with their resp. caveats.

* Nevertheless it only describes ELF-based systems, and mostly systems using Drepper's own .so-loader.

* Portability to e.g. Windows is a almost impossible for you, because it doesn't support undefined symbols in .sos (and Drepper suggests on ELF-based systems this should only be used if absolutely unavoidable, IIRC).  NB:  There is a project on SF which claimes to provide this feature on Windows, but I haven't tried and it limits your choice of tools (http://edll.sf.net/).


cheers,

aa

-- 
Andreas Ames | Programmer | Comergo GmbH |
Voice:  +49 711 13586 7789 | ames AT avaya DOT com



More information about the Python-list mailing list