我一直在試圖使用Boost在Windows 7擴展Python和C++這是我的代碼至今:試圖接口的Python 3與C++使用Boost
C++代碼,hellomodule.cpp:
#include <iostream>
using namespace std;
void say_hello(const char* name) {
cout << "Hello " << name << "!\n";
}
#include <boost/python/module.hpp>
#include <boost/python/def.hpp>
using namespace boost::python;
BOOST_PYTHON_MODULE(hello) {
def("say_hello", say_hello);
}
Python代碼,setup.py:
#!/usr/bin/env python
from distutils.core import setup
from distutils.extension import Extension
setup(name="PackageName",
ext_modules = [
Extension("hello", ["hellomodule.cpp"],
libraries = ["boost_python"])
]
)
我嘗試在我Python32目錄中打開命令提示符,然後運行 「蟒蛇setup.py構建」 建立這個。我在我的環境變量中包含了vcvarsall.bat的路徑。
現在我得到的錯誤:
。
我幾乎沒有使用C++的經驗,而且我是Boost的新手。任何幫助,將不勝感激。
編輯:這是在MVSC++ 2010中完成的,但是我使用的是v9.0工具集,並且也在MVSC++ 2008 Express中嘗試過。 hellomodule.cpp的路徑是「C:\ Users \ Amir \ Documents \ Visual Studio 2010 \ Projects \ BoostExample \ BoostExample \ hellomodule.cpp」
「hellomodule.cpp」:沒有這樣的文件或目錄,它意味着你有錯誤的路徑 – fazo 2012-02-27 22:07:46