【发布时间】:2013-11-17 14:56:42
【问题描述】:
有一些问题,现在我已经阅读了以下内容:
hello world python extension in c++ using boost?
我已经尝试将 boost 安装到我的桌面上,并且按照帖子在链接方面的建议完成。我有以下代码:
#include <boost/python.hpp>
#include <Python.h>
using namespace boost::python;
现在我尝试使用以下链接:
g++ testing.cpp -I /usr/include/python2.7/pyconfig.h -L /usr/include/python2.7/Python.h
-lpython2.7
我也尝试了以下方法:
g++ testing.cpp -I /home/username/python/include/ -L /usr/include/python2.7/Python.h -lpython2.7
我不断收到以下错误:
/usr/include/boost/python/detail/wrap_python.hpp:50:23: fatal error: pyconfig.h: No such
file or directory
# include <pyconfig.h>
我不知道我哪里出错了。我确实安装了 boost.python,只是链接有问题?
【问题讨论】:
-
首先,在我看到的所有示例中,在我的代码中,-I 和之后的路径之间没有空格(-L 也是如此)。第二,你确定你的路径是正确的吗?通常 python 包含文件在 /usr/include/python
-
这些是编译器错误,而不是链接器错误。是否安装了 Python 开发者头文件?它们通常分布在开发者包中,例如
python-dev。
标签: c++ ubuntu gcc boost boost-python