[Pythonmac-SIG] Python C extensions that depend on dynamic libraries

Jack Jansen Jack.Jansen at cwi.nl
Sun Jan 11 15:53:10 EST 2004


On 11-jan-04, at 18:38, Bob Ippolito wrote:

>> 3. Build C++ library as dynamic library then build Python extension 
>> dependent on it.  So I have a python shadow/proxy class file foo.py 
>> that loads the actual python extension _foo.so that depends on the 
>> C++ library foo.dylib. I have have set DYLD_LIBRARY_PATH, etc. The 
>> behavior I see is that if I import foo, it imports _foo.so and then 
>> Python hangs, forever. I have to kill it from the commandline.
>
> This is probably something to do with the C++ runtime.. as a hunch, do 
> you have any static initialization in your C++ dynamic library?  If it 
> works with DYLD_BIND_AT_LAUNCH, then that's probably the case.  What's 
> it doing in gdb when you break it?

If Bob is right (and I think he is) then you can probably fix this by 
using "g++" in stead of "ld" or "gcc" as the linker command for your 
Python extension.

Although, Bob, I'm not sure about your DYLD_BIND_AT_LAUNCH suggestion. 
Is that also honored for plugins (as the Python extension modules are)?

Bob Tolbert also wrote:
> So now that I've bored you with more details than I should have, I am 
> really asking for some ideas of where to look for the straight scoop 
> on the is whole dylib/so dichotomy in OS X.

You've definitely not bored us with the details! It's much better if 
people post as many details as they can possibly think of, even if 80% 
of them are insignificant the 20% that you don't have to go ask for 
makes life a whole lot easier!

As to the dylib/so issue: that's my stupidity. Back when OSX came out I 
was under the impression (don't know where I got it) that both .dylib 
and .so were "legal" extensions for dynamic libraries on OSX. As .so 
was the standard on most unixen, and for some reason Python's configure 
seemed to pick that I never spent a second thought on it.

I'm not sure what we'll do for 2.4. Either go to whatever is the 
standard on OSX (I haven't a clue whether there is a standard for 
plugins), or come up with one ourselves (.pysomethingorother).
--
Jack Jansen, <Jack.Jansen at cwi.nl>, http://www.cwi.nl/~jack
If I can't dance I don't want to be part of your revolution -- Emma 
Goldman




More information about the Pythonmac-SIG mailing list