【发布时间】:2012-02-27 22:03:52
【问题描述】:
我一直在尝试在 Windows 7 中使用 Boost 使用 C++ 扩展 Python。这是我目前拥有的代码:
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 目录中运行“python setup.py build”来构建它。我在环境变量中包含了 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': 没有这样的文件或目录。这意味着你的路径错误