From: William S F. <ws...@fu...> - 2006-12-20 23:17:06
|
Josh Cherry wrote: > > On Tue, 19 Dec 2006, Geoffrey Hutchison wrote: > >> One thing we discovered when writing the Perl and Python bindings >> with SWIG was that these internal dlopen() calls broke unless we >> hacked the SWIG output to add something like this: >> import sys >> if sys.platform.find(\"linux\") != -1: >> import dl >> sys.setdlopenflags(sys.getdlopenflags() | dl.RTLD_GLOBAL) >> >> >> Now I don't code on Linux, so it's hard for me to test these things. >> I don't know if the problem is that our C++ library should be calling >> RTLD_LAZY|RTLD_GLOBAL when it loads the format shared objects. >> >> -or- >> >> That we need some way to set the options when the SWIG interfaces >> load our library. > > I ran into this issue when doing multiple modules. My understanding is > that sys.setdlopenflags only affects what flags Python uses when it does a > dlopen, such as the one it does when you import a shared library. I don't > think Python could affect what your C++ library does if it wanted to. So > I think the second possibility is correct. The first might come up as an > issue, but it wouldn't be fixed by the setdlopenflags. > > BTW, after importing you should probably set the flags back to what they > were in case it matters to other modules. > I don't recall seeing this query on the SWIG mailing list for Java before, so you might want to ask on the Sun JNI forums instead as the problem is independent of whether or not SWIG is being used to generate the JNI code. Perhaps you can set these flags in the JNI_OnLoad handler, otherwise there might be a JVM system property which equates to setting these flags? William |