[Pythonmac-SIG] extensions linked against shared library?

Ralf W. Grosse-Kunstleve rwgk at yahoo.com
Sat Aug 19 02:04:57 CEST 2006


I am wondering if it is possible to use Boost.Python based
C++ extension modules with a non-framework Python 2.5 build.

At runtime I'd like to import two different C++ extension
modules. Both modules need to dynamically link against
libboost_python:

                  |------|
                  |python|
                  |------|
                     |
                   import
                     |
            ---------------------
            |                   |
    |---------------|   |---------------|
    |C++ extension 1|   |C++ extension 2|
    |---------------|   |---------------|
            |                   |
            ---------------------
                     |
              dynamically linked
                     |
             |---------------|
             |libboost_python|
             |---------------|

I built python simply with ./configure --prefix=...; make; make install.

I created libboost_python with:

  setenv MACOSX_DEPLOYMENT_TARGET 10.3
  c++ -o lib/libboost_python.dylib -dynamic -undefined dynamic_lookup $bplobj

where $bplobj is a list of *.o files.

When I try to link a C++ extension module like this

  c++ -bundle -undefined dynamic_lookup -o lib/boost_python_meta_ext.so
boost_adaptbx/meta_ext.o -Llib -lboost_python

the result is

  ld: lib/libboost_python.dylib is input for the dynamic link editor, is not
relocatable by the static link editor again

Is there any way to make this work? -- It works with the framework
Python that ships with OS X 10.3 and 10.4, but I'd like to know
if it could also work with a non-framework Python.

Ralf

P.S.: I am working on a Mac OS X 10.3 system with gcc version 3.3 20030304
(Apple Computer, Inc. build 1493)


__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 


More information about the Pythonmac-SIG mailing list