简体   繁体   中英

Building a Python extension with bjam (Boost.Build) on Mac OS X

So far as I can tell what happens is this:

  • In python.jam , it works out which version of Python I am using and which library directories to look in;
  • It adds -Wl-R arguments to the g++ command line to include those directories;
  • The ld command complains that it does not have a -R option.

So either (a) I have a defective version of ld , or (b) I need to tell bjam that it needs to use a different option ( -rpath perhaps?) or that this option is not required.

I must be missing something—I am surely not the first person in history to try to build a Python extension with Boost on Mac OS X—but I can't figure out where to look next. Any hints?

Update:

The command I am using is

bjam

If I do bjam --version , I get

Boost.Build V2 (Milestone 12)
Boost.Jam 03.1.18

The toolset used is whatever the default toolset is on Mac OS X.

The compiler is the default compiler on Mac OS X (with the developer tools installed), which is GCC version 'i686-apple-darwin10-gcc-4.2.1 (GCC) 4.2.1 (Apple Inc. build 5664)'.

The linker is the default linker on Mac OS X, which is called ld or ld64 , but which does not have the -R option that GNU ld has, so I assume it is a special version designed to allow for Mac OS X's concept of frameworks or whatever. It does not have a --version option.

There is a Jamfile , which goes like this:

import python ;

python-extension _optimor :
    bill_python.cpp
    bill_record_python.cpp
    .. etc ...
    :
    <cxxflags>-fPIC
    ... etc ...
    <variant>debug:<define>DEBUG
    <include>/usr/include/python2.6
    <include>../
    ;

It builds OK on Ububtu GNU/Linux.

I am not interested in Boost or bjam per se; my only requirement to compile this extension so I can get on with developing the system of which this extension is a small but important part.

I can't tell which version of Boost you have.. BUt the most likely reason for the problem is that you are using the generic "gcc" toolset to build. There's a special toolset for building with the GCC variant that Apple uses in Xcode. Try building with bjam toolset=darwin instead.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM