Boost python in OS X, with non-framework python 2.4
Hello! [apologies for long post ahead] I've been using boost python with some of my research code for a little while on linux, and have really enjoyed it. I've been having trouble on my new mac laptop though, since (a) I have a large codebase that needs python2.4, and (b) I can't seem to compile and link boost python extensions against python2.4 as provided by fink or darwin ports. No matter what I try, I can only get extensions successfully compiled for the framework python2.3 which comes with OS X. I know this because with python 2.4 (from fink) my code gives Fatal Python error: Interpreter not initialized (version mismatch?) Abort trap whereas this doesn't occur with 2.3, where the extension works fine. If I use boost.python from fink or darwin ports, the problem is the same. I've tried installing my own version, using configure arguments --with-python=/sw/bin/python2.4 --with-python-root=/sw --with-python-version=2.4 --with-libraries=python. Here's the output from the previous compilation stage for my extension, which appears to be successful: g++ -o dataType.o -c -Wall -O3 -fPIC -I/sw/include/python2.4 -I/usr/local/include/boost dataType.cpp g++ -o entry.o -c -Wall -O3 -fPIC -I/sw/include/python2.4 -I/usr/local/include/boost entry.cpp g++ -o alignment.o -c -Wall -O3 -fPIC -I/sw/include/python2.4 -I/usr/local/include/boost alignment.cpp g++ -o ambiguousAlignment.o -c -Wall -O3 -fPIC -I/sw/include/python2.4 -I/usr/local/include/boost ambiguousAlignment.cpp g++ -o utils.o -c -Wall -O3 -fPIC -I/sw/include/python2.4 -I/usr/local/include/boost utils.cpp g++ -o dataType.dylib -dylib -bundle -L/sw/lib -lpython2.4 -lboost_python -lm dataType.o entry.o alignment.o ambiguousAlignment.o utils.o I did see some earlier posts on this, but they seemed a bit unresolved. From my understanding, regardless of command line options you give to configure, if you compile boost.python using the darwin toolset, it links against the framework python. I tried building using the gcc toolset, and specifying --with-python=/sw/bin/python2.4 --with-python-root=/sw --with-python-version=2.4 --with-libraries=python. If you do this, the g++ arguments are actually wrong for OS X, and you have to manually perform the final linking step yourself. This works, if you change c++ -s -fPIC -shared -o <target dylib> <long list of object files> to c++ -dynamiclib -dynamic -o <target dylib> <long list of object files> -L/sw/lib -lpython2.4 for the targets libboost_python-gcc-1_33_1.dylib and libboost_python-gcc-d-1_33_1.dylib (leaving in the -g flag for the debug library). I can then install it. After all this, I try recompiling. g++ -o dataType.o -c -Wall -O3 -fPIC -I/sw/include/python2.4 -I/usr/local/include/boost dataType.cpp g++ -o entry.o -c -Wall -O3 -fPIC -I/sw/include/python2.4 -I/usr/local/include/boost entry.cpp g++ -o alignment.o -c -Wall -O3 -fPIC -I/sw/include/python2.4 -I/usr/local/include/boost alignment.cpp g++ -o ambiguousAlignment.o -c -Wall -O3 -fPIC -I/sw/include/python2.4 -I/usr/local/include/boost ambiguousAlignment.cpp g++ -o utils.o -c -Wall -O3 -fPIC -I/sw/include/python2.4 -I/usr/local/include/boost utils.cpp g++ -o dataType.so -dylib -bundle -L/sw/lib -lpython2.4 -lboost_python-gcc-1_33_1 -lm dataType.o entry.o alignment.o ambiguousAlignment.o utils.o Now, when I test, I get same error, but with python2.3, python2.4 and python2.5. This to me indicates that either my library, or boost's library, has been compiled with a mixture of python flavours, acceptable to none. Does anyone have any ideas on what else I could try, or suggestions in the case I'm barking up the wrong tree? Many thanks, Lars
participants (1)
-
Lars Yencken