[Pythonmac-SIG] weak-link libraries problem

Bob Ippolito bob at redivi.com
Wed Apr 12 04:24:39 CEST 2006


On Apr 11, 2006, at 6:46 PM, William Kyngesburye wrote:

> I just ran into an odd and annoying problem - I'm building a Python
> library/extension thing for a package (MapServer) and have a library
> weak-linked (it's to a non-open source product, this is so others
> don't have to install that if they don't need it and I don't have to
> build multiple versions...).  Python's import seems to ignore that, I
> suspect it's doing it's own library loading thing and checking all
> symbols or something.
>
> Is this normal?  Is there a way to make Python NOT do it?  Or am I
> stuck with it?

I'm not entirely sure, I haven't tried it.  It uses these NSModule  
flags to load extensions:
	NSLINKMODULE_OPTION_BINDNOW
	NSLINKMODULE_OPTION_RETURN_ON_ERROR
	NSLINKMODULE_OPTION_PRIVATE

I don't believe that any of those options would defeat weak linking,  
though.

You might have to find the library at runtime with the dyld or dl  
APIs and it use that way.  Or strong-link to it in a separate  
extension that's only loaded if the library is detected.

-bob



More information about the Pythonmac-SIG mailing list