Boost.Python的蟒蛇链接错误 [英] Boost.Python python linkage error

查看:433
本文介绍了Boost.Python的蟒蛇链接错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我接触到最新的Boost发布(1.55.0)运行Mac OS X 10.8.4(达尔文12.4.0)。我按照指示的此处建设列入我分发教程升压Python项目,它建立的罚款。

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 my distribution, and it builds fine.

不过,输出编译库依赖于Mac的系统的Python,而不是蟒蛇的Python的我试图链接:

Nonetheless, the output compiled libraries depend on Mac's system Python and not the anaconda Python that I'm trying to link to:

[00:20] [tutorial] $ otool -L libboost_python.dylib
libboost_python.dylib:
    libboost_python.dylib (compatibility version 0.0.0, current version 0.0.0)
    libpython2.7.dylib (compatibility version 2.7.0, current version 2.7.0)
    /opt/local/lib/libgcc/libstdc++.6.dylib (compatibility version 7.0.0, current version 7.18.0)
    /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 169.3.0)
    /opt/local/lib/libgcc/libgcc_s.1.dylib (compatibility version 1.0.0, current version 1.0.0)

[00:20] [tutorial] $ otool -L /usr/lib/libpython2.7.dylib
/usr/lib/libpython2.7.dylib:
    /System/Library/Frameworks/Python.framework/Versions/2.7/Python (compatibility version 2.7.0, current version 2.7.2)
    /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 169.3.0)

我试过以下的配置,但他们都不改变要使用的Python的:

I've tried the following configurations, but none of them seem to change which Python to use:

$BOOST_ROOT/bootstrap.sh --with-python=$ANACONDA_PATH/bin/python

# Here, I've explicitly chosen Anaconda-provided libpython2.7.dylib
# $BOOST_ROOT/stage/lib/libboost_python.dylib refers to the dynamic
# version of boost_python.
sudo g++ -I$BOOST_ROOT -I$ANACONDA_PATH/include -L$ANACONDA_PATH/lib
    -lpython2.7 $BOOST_ROOT/stage/lib/libboost_python.dylib
    hello.cpp -o hello_ext.so

$BOOST_ROOT/bjam python=$ANACONDA_PATH/bin/python

不管是什么,我会永远得到这个消息:

No matter what, I'll always get this message:

[01:58] [tutorial] $ python hello.py
Fatal Python error: PyThreadState_Get: no current thread
Abort trap: 6

下面是比较系统的Python调用:

Here's the system Python call in comparison:

[01:58] [tutorial] $ /usr/bin/python hello.py
hello, world


相似:<一href=\"http://stackoverflow.com/questions/15678153/homebrew-python-on-mac-os-x-10-8-fatal-python-error-pythreadstate-get-no-cu\">Homebrew +的Python在Mac OS X 10.8:致命的Python错误:PyThreadState_Get:没有当前线程进口Mapnik的

推荐答案

我通过解决这个问题,安装名称工具来改变相关的名称 dylib

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


  1. 要更改许可你的 libboost_python.dylib

搭配chmod + W libboost_python.dylib

然后,更改相关的 dylib

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

希望这是有帮助的。

这篇关于Boost.Python的蟒蛇链接错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆