2

私はubuntu12.04でboost:pythonの例を作成しようとしています。(ソースからではなく)パッケージマネージャーからライブラリをインストールしました。また、これまでブーストを使用したことはなく、このための環境変数も設定していません(BOOST_BUILD_PATHは設定されていません)。このエラーが発生します:

/usr/share/doc/libboost1.46-doc/examples/libs/python/example/tutorial$ bjam --debug-configuration
notice: found boost-build.jam at /usr/share/doc/libboost1.46-doc/examples/libs/python/example/boost-build.jam
Unable to load Boost.Build: could not find build system.
---------------------------------------------------------
/usr/share/doc/libboost1.46-doc/examples/libs/python/example/boost-build.jam attempted to load the build system by invoking
'boost-build ../../../tools/build/v2 ;'
but we were unable to find "bootstrap.jam" in the specified directory
or in BOOST_BUILD_PATH (searching /usr/share/doc/libboost1.46-doc/examples/libs/python/example/../../../tools/build/v2, /usr/share/boost-build).
Please consult the documentation at 'http://www.boost.org'.

どうすれば修正できますか?BOOST_BUILD_PATHをどこにポイントすればよいですか?

4

1 に答える 1

6

私は同じ問題を抱えていましたが、ここで解決策を見つけました:

http://jayrambhia.wordpress.com/2012/06/25/configuring-boostpython-and-hello-boost/

bjam をまったく使用する必要がないことがわかりました。メイクファイルで十分です。上記のリンクからの解決策をここで繰り返します。

1.) libboost-python パッケージをインストールする

2.) 「hello_ext.c」という名前の hello world ソース ファイルを作成します。

char const* greet()
{
    return "hello, world";
}

#include<boost/python.hpp>
BOOST_PYTHON_MODULE(hello_ext)
{
   using namespace boost::python;
   def("greet",greet);
}

3.) メイクファイルを作成します。

PYTHON_VERSION = 2.7
PYTHON_INCLUDE = /usr/include/python$(PYTHON_VERSION)
# location of the Boost Python include files and library
BOOST_INC = /usr/include
BOOST_LIB = /usr/lib
# compile mesh classes
TARGET = hello_ext
$(TARGET).so: $(TARGET).o
    g++ -shared -Wl,--export-dynamic $(TARGET).o -L$(BOOST_LIB) -lboost_python -L/usr   /lib/python$(PYTHON_VERSION)/config -lpython$(PYTHON_VERSION) -o $(TARGET).so
$(TARGET).o: $(TARGET).c
    g++ -I$(PYTHON_INCLUDE) -I$(BOOST_INC) -fPIC -c $(TARGET).c

4.) 作る

make

5.) すぐに使用できます。パイソンでは:

import hello_ext
print hello_ext.greet()

タブを含めるように編集されました。

于 2013-02-09T20:16:42.380 に答える