Skip to content Skip to sidebar Skip to footer

Boost.python Python Linkage Error

I'm running Mac OS X 10.8.4 (Darwin 12.4.0) with the lastest Boost distribution (1.55.0). I'm following the instructions here to build the tutorial Boost-Python project included in

Solution 1:

After trying many other solutions I found on the web, I lost patience and decided to go with my own (very-bad) hack. I've created 2 bash scripts, one to link the sys's Python to Anaconda's, and one to relink back to the original Python:

ana_py.sh:

#!/usr/bin/env bash# Link to Anaconda's Python# $ANACONDA_PATH is the path to your anaconda folder# BINcd /usr/bin

if [ ! -h python ]; then
    sudo mv python python_orig;
else
    sudo unlink python;
fi
sudo ln -s $ANACONDA_PATH/bin/python python

if [ ! -h python-config ]; then
    sudo mv python-config python-config_orig;
else
    sudo unlink python-config;
fi
sudo ln -s $ANACONDA_PATH/bin/python-config python-config

# INCLUDEcd /usr/include

sudo unlink python2.7
sudo ln -s $ANACONDA_PATH/include/python2.7 python2.7

# LIBcd /usr/lib

sudo unlink python2.7
sudo unlink libpython2.7.dylib
sudo ln -s $ANACONDA_PATH/lib/python2.7 python2.7
sudo ln -s $ANACONDA_PATH/lib/libpython2.7.dylib libpython2.7.dylib

sys_py.sh:

#!/usr/bin/env bash# Link to Mac OSX Python# BINcd /usr/bin

sudo unlink python
if [ -f python_orig ]; then
    sudo mv python_orig python;
else
    sudo ln -s /System/Library/Frameworks/Python.framework/Versions/2.7/bin/python python;
fi

sudo unlink python-config
if [ -f python-config_orig ]; then
    sudo mv python-config_orig python-config;
else
    sudo ln -s /System/Library/Frameworks/Python.framework/Versions/2.7/bin/python-config python-config;
fi# INCLUDEcd /usr/include

sudo unlink python2.7
sudo ln -s /System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7 python2.7

# LIBcd /usr/lib

sudo unlink python2.7
sudo unlink libpython2.7.dylib
sudo ln -s /System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7 python2.7
sudo ln -s /System/Library/Frameworks/Python.framework/Versions/2.7/Python libpython2.7.dylib

Once you've run ana_py.sh, you can run bootstrap.sh, b2, & bjam without providing/modifying any of their Python parameters/options

Solution 2:

I solve this problem by using install-name-tool to change the name of the dependent dylib:

  1. To change the permission of your libboost_python.dylib:

    chmod +w libboost_python.dylib

  2. Then change the dependent dylib:

    install_name_tool -change libpython2.7.dylib /path/to/anaconda/lib/libpython2.7.dylib "libboost_python.dylib"

Hope it is helpful.

Post a Comment for "Boost.python Python Linkage Error"