[Pythonmac-SIG] _environ

Brian Lenihan brian_l at mac.com
Mon Aug 11 23:56:47 EDT 2003


On Monday, August 11, 2003, at 7:28 PM, Keith Jackson wrote:

> Sorry if this has been asked before, but the only refs I found were 
> back in 2002. I just built python 2.3 using the mac build 
> instructions, so it is built as a framework. I then tried to build 
> some of my extension modules and they would fail with an undefined 
> symbol error for _environ. nm shows that this is defined in the python 
> executable. Looking through the linker man page, I see that since two 
> level namespaces are being used it wants to resolve all symbols at 
> static link time.
>
> To fix this problem, I added in "-bundle_loader 
> /usr/local/bin/python". I think this tells the linker to look in the 
> python executable to find symbols. Does anybody know if this is the 
> *right* thing to do? Can I safely add this into my python 
> config/Makefile so all extension builds do this?

I've sometimes resorted to doing something like the fragment, below, to 
fix other people's extensions when I'm too lazy to go through the whole 
tool chain and fix it properly:

#if defined (__APPLE__)
#include <crt_externs.h>
#define environ (* _NSGetEnviron())
#endif

Since you are using a framework build, you should be able to use 
-framework Python for your extensions.  grep for bundle_loader in 
Python's configure file.  It will give you a pretty good idea of what 
to do.




More information about the Pythonmac-SIG mailing list