[Pythonmac-SIG] problems with boost.python on OS X

stephan nies nies.stephan at googlemail.com
Tue Feb 6 21:46:32 CET 2007


Thank you,

now I got one step further.
The only issue that remains is when i import myextension
the libboost_python-1_33_1.dylib on which it depends is not found.
Also i set up the DYLD_LIBRARY_PATH accordingly or is this the
wrong place? sorry, if i might miss some OS X  special again.

ImportError: Failure linking new module: myextension.so: Library not
loaded: libboost_python-1_33_1.dylib
  Referenced from: myextension.so
  Reason: image not found

echo $DYLD_LIBRARY_PATH
:/Users/nies/src/boost_1_33_1/bin/boost/libs/python/build/libboost_python.dylib/darwin/debug/shared-linkable-true/

otool -L myextension.so
myextension.so:
        /Library/Frameworks/Python.framework/Versions/2.4/Python
(compatibility version 2.4.0, current version 2.4.0)
        /System/Library/Frameworks/OpenGL.framework/Versions/A/OpenGL
(compatibility version 1.0.0, current version 1.0.0)
        /System/Library/Frameworks/GLUT.framework/Versions/A/GLUT
(compatibility version 1.0.0, current version 1.0.0)
        libboost_python-1_33_1.dylib (compatibility version 0.0.0,
current version 0.0.0)
        /usr/lib/libstdc++.6.dylib (compatibility version 7.0.0,
current version 7.4.0)
        /usr/lib/libgcc_s.1.dylib (compatibility version 1.0.0,
current version 1.0.0)
        /usr/lib/libSystem.B.dylib (compatibility version 1.0.0,
current version 88.1.7)

But many Thanks Thorsten,
Vielen Dank,
Stephan


On 2/6/07, Torsten Sadowski <torsten.sadowski at tu-berlin.de> wrote:
> Hello,
>
> as far as I know, Python extensions are OSX bundles. Try -bundle instead
> of -dynamiclib.
>
> Just a guess.
>
> Cheers, Torsten
>
> Am Dienstag, 6. Februar 2007 17:55 schrieb stephan nies:
> > Hello,
> >
> > has anyone used boost.python on OSX
> > and can help me or point me
> > to "hello world"-style example of a
> > c++ - extension in boost.python
> > that works on OSX.
> >
> > I have used boost.python on linux and
> > am porting the app from linux to osx.
> > Since the app uses a
> > boost.python - extension module
> > its essential for me to get the extension
> > working.
> >
> > At the Moment everything compiles
> > but i cant import the extension in python.
> >
> > I already posted on C++-sig but didn't get response so far.
> > http://mail.python.org/pipermail/c++-sig/2007-February/011918.html
> >
> >
> > My Situation:
> >
> > OS:        PPC Mac OS X 10.4.8
> > Python:   python-2.4.4-macosx2006-10-18.dmg
> >              from http://pythonmac.org/packages/py24-fat/dmg/
> >              (this is a framework build)
> > Boost:    1.33.1 build from source (./configure && make)
> >
> > i am building my extension by invoking:
> >
> > g++ -dynamic myextension.cpp
> > -I/Library/Frameworks/Python.framework/Headers
> > -I/System/Library/Frameworks/GLUT.framework/Headers -I/usr/include
> > -I/Users/nies/src/boost_1_33_1 -c -o myextension.o
> >
> > and
> >
> > g++ -v -dynamiclib -framework Python -framework OpenGL -framework GLUT
> > -L/Users/nies/src/boost_1_33_1/bin/boost/libs/python/build/libboost_python.
> >dylib/darwin/release/shared-linkable-true/ -lboost_python-1_33_1
> > myextension.o -o myextension.dylib
> >
> > this compiles and when i try to import the extension in pythonw:
> >
> > Python 2.4.4 (#1, Oct 18 2006, 10:34:39)
> > [GCC 4.0.1 (Apple Computer, Inc. build 5341)] on darwin
> > Type "help", "copyright", "credits" or "license" for more information.
> >
> > >>> import myextension
> >
> > Traceback (most recent call last):
> >  File "<stdin>", line 1, in ?
> > ImportError: No module named myextension
> >
> > as far as i understand this is because python searches for
> > .so files.  when i symbolic-link  myextension.so -> myextension.dylib
> > and than try to import:
> >
> > Python 2.4.4 (#1, Oct 18 2006, 10:34:39)
> > [GCC 4.0.1 (Apple Computer, Inc. build 5341)] on darwin
> > Type "help", "copyright", "credits" or "license" for more information.
> >
> > >>> import myextension
> >
> > Traceback (most recent call last):
> >  File "<stdin>", line 1, in ?
> > ImportError: Inappropriate file type for dynamic loading
> >
> > so what am i doing wrong here? I would really
> > appreciate some hints at this point.
> >
> > Thanks,
> > Stephan
> > _______________________________________________
> > Pythonmac-SIG maillist  -  Pythonmac-SIG at python.org
> > http://mail.python.org/mailman/listinfo/pythonmac-sig
>
> _______________________________________________
> Pythonmac-SIG maillist  -  Pythonmac-SIG at python.org
> http://mail.python.org/mailman/listinfo/pythonmac-sig
>


More information about the Pythonmac-SIG mailing list