2013-06-30 85 views
1

我試圖運行 hello world boost python example乍一看一切都很好。我得到以下輸出奮鬥與提升:: python

>bjam 
...patience... 
...patience... 
...found 1727 targets... 
...updating 9 targets... 
gcc.compile.c++ bin/gcc-4.7/debug/hello.o 
gcc.link.dll bin/gcc-4.7/debug/hello_ext.so 
common.copy libboost_python.so.1.53.0 
ln-UNIX libboost_python.so 
ln-UNIX libboost_python.so.1 
ln-UNIX libboost_python.so.1.53 
common.copy hello_ext.so 
capture-output bin/hello.test/gcc-4.7/debug/hello 
**passed** bin/hello.test/gcc-4.7/debug/hello.test 
...updated 9 targets... 

然而,當我嘗試在Python中使用它,我得到一個導入錯誤消息

>python 
Python 2.7.4 (default, Apr 19 2013, 18:32:33) 
[GCC 4.7.3] on linux2 
Type "help", "copyright", "credits" or "license" for more information. 
>>> import hello 
Traceback (most recent call last): 
    File "<stdin>", line 1, in <module> 
    File "hello.py", line 6, in <module> 
    import hello_ext 
ImportError: libboost_python.so.1.53.0: cannot open shared object file: No such file or directory 

回答

1

您需要配置您的環境中找到Boost庫。這與python沒有多大關係,但是增強安裝。最快的方法是擴展LD_LIBRARY_PATH環境變量。

看一看這裏:

Error loading shared libraries of boost