[Pythonmac-SIG] _environ
Keith Jackson
krjackson at lbl.gov
Fri Aug 15 16:27:10 EDT 2003
All right, I'm totally confused. :) Any help would be *greatly*
appreciated. I can build other extension modules, and everything is
fine. It is just my modules that exhibit the problem with _environ.
Clearly I'm doing something wrong, but I don't have a clue what it is.
I've attached working output from a build of m2crypto, and broken
output from my build. If anyone has any ideas about what I'm doing
wrong, please let me know.
thanks,
--keith
working m2crypto extension build:
gcc -fno-strict-aliasing -Wno-long-double -no-cpp-precomp
-mno-fused-madd -fno-common -dynamic -DNDEBUG -g -O3 -Wall
-Wstrict-prototypes -I/Users/kjackson/src/m2crypto-0.11/SWIG
-I/sw/include
-I/Library/Frameworks/Python.framework/Versions/2.3/include/python2.3
-c SWIG/_m2crypto_wrap.c -o
build/temp.darwin-6.6-Power_Macintosh-2.3/SWIG/_m2crypto_wrap.o
-DTHREADING
gcc -Wl,-F. -bundle -framework Python
build/temp.darwin-6.6-Power_Macintosh-2.3/SWIG/_m2crypto_wrap.o
-L/sw/lib -lssl -lcrypto -o
build/lib.darwin-6.6-Power_Macintosh-2.3/M2Crypto/__m2crypto.so
broken extension build:
gcc -fno-strict-aliasing -Wno-long-double -no-cpp-precomp
-mno-fused-madd -fno-common -dynamic -DNDEBUG -g -O3
-I/sw/globus/globus/include/gcc32dbgpthr
-I/Library/Frameworks/Python.framework/Versions/2.3/include/python2.3
-c src/util_wrap.c -o
build/temp.darwin-6.6-Power_Macintosh-2.3/src/util_wrap.o -g
-fno-common -I/sw/include -D_REENTRANT -Wall
cc1: warning: ` -fno-common -I/sw/include -D_REENTRANT -Wall
': unknown or unsupported -g option
gcc -Wl,-F. -bundle -framework Python
build/temp.darwin-6.6-Power_Macintosh-2.3/src/util_wrap.o
-L/sw/globus/globus/lib -L/sw/globus/globus/lib -L/sw/lib -L/sw/lib
-lglobus_common_gcc32dbgpthr -lpthread -o
build/lib.darwin-6.6-Power_Macintosh-2.3/pyGlobus/utilc.so
ld: Undefined symbols:
_environ
error: command 'gcc' failed with exit status 1
On Monday, August 11, 2003, at 10:56 PM, Brian Lenihan wrote:
>
> 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