RTLD_GLOBAL cures my g++ + Boost.Python + cross module blues?
I've recently come across a method to get my g++ compiled Boost.Python classes wrapped in different shared libraries to work (cross module class inheritance, dynamic_cast, etc.), and I thought I'd share this to see if it's useful to anyone else here, as well as see if anyone knows of any problems with this approach. For completeness I'm using Python 2.3.4, g++ 3.4.1, and the last Boost release (1.32.0) on Linux x86. When compiling with g++ I've been plagued by the cross library type_info problems described elsewhere (http://www.python.org/moin/boost.python/CrossExtensionModuleDependencies), but recently I discovered that if I force python's dlopen to use RTLD_GLOBAL then upon importing my extensions the different libraries resolve these type_info problems and everything starts working. All I've done is issue the following python commands before importing any Boost.Python wrapped code: import sys, dl sys.setdlopenflags(dl.RTLD_NOW|dl.RTLD_GLOBAL) While this seems to have solved all of my current cross-library problems, I'm suspicious that it could be this simple. Does anyone else here have any experience with these g++/Boost.Python/cross module issues? Is there a reason the above might be a bad idea? Mike. -- "Hey...where are the sunflower seeds?" | J. Michael Owen o_o / | (") | Email: mikeowen@llnl.gov \/'\/ | ____(__(,_,)_______________________________________________________________
On Wed, 2005-04-20 at 17:50 -0700, J. Michael Owen wrote:
import sys, dl sys.setdlopenflags(dl.RTLD_NOW|dl.RTLD_GLOBAL)
While this seems to have solved all of my current cross-library problems, I'm suspicious that it could be this simple. Does anyone else here have any experience with these g++/Boost.Python/cross module issues? Is there a reason the above might be a bad idea?
This is what I do. The only possible problem, I think, is that the symbols might conflict with other C modules you will load later. Using namespaces should make this unlikely, and I typically reset dlopenflags back to normal (i.e. no RTLD_GLOBAL) once I've imported my boost module. And of course this won't work on Windows :)
participants (2)
-
Itamar Shtull-Trauring -
J. Michael Owen