Ubuntu - 链接 boost.python - 致命错误:找不到 pyconfig

Ubuntu - Linking boost.python - Fatal error: pyconfig cannot be found(Ubuntu - 链接 boost.python - 致命错误:找不到 pyconfig)
本文介绍了Ubuntu - 链接 boost.python - 致命错误:找不到 pyconfig的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

问题描述

遇到一些问题,现在我已阅读以下内容:

Having some issues, now I have read the following:

hello world python 扩展在 C++ 中使用 boost?

我已经尝试将 boost 安装到我的桌面上,并且按照链接方面的建议完成.我有以下代码:

I have tried installing boost onto my desktop, and, done as the posts suggested in terms of linking. I have the following code:

#include <boost/python.hpp>
#include <Python.h>
using namespace boost::python;

现在我尝试与以下链接:

Now I have tried linking with the following:

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 don't know where I am going wrong. I do have boost.python installed, there's just a problem linking?

推荐答案

我刚遇到同样的错误,问题是 g++ 找不到 pyconfig.h(令人震惊,我知道).对我来说,这个文件位于 /usr/include/python2.7/pyconfig.h 所以附加 -I/usr/include/python2.7/ 应该修复它,或者,您可以使用以下命令将目录添加到您的路径中:

I just had the same error, the problem is g++ can't find pyconfig.h(shocking, I know). For me this file is located in /usr/include/python2.7/pyconfig.h so appending -I /usr/include/python2.7/ should fix it, alternatively you can add the directory to your path with:

export CPLUS_INCLUDE_PATH="$CPLUS_INCLUDE_PATH:/usr/include/python2.7/"

您也可以将它添加到您的 .bashrc 中,它会在您下次启动 shell 时添加(您必须重新打开终端才能实现更改).

You can also add this to your .bashrc and it will be added whenever you start your shell next(you will have to reopen your terminal to realize the changes).

您可以使用 find/usr/include -name pyconfig.h 找到自己的 python 包含路径,在我的情况下返回:

You can find your own python include path by using find /usr/include -name pyconfig.h, in my case this returns:

/usr/include/python2.7/pyconfig.h
/usr/include/i386-linux-gnu/python2.7/pyconfig.h

这篇关于Ubuntu - 链接 boost.python - 致命错误:找不到 pyconfig的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

相关文档推荐

What do compilers do with compile-time branching?(编译器如何处理编译时分支?)
Can I use if (pointer) instead of if (pointer != NULL)?(我可以使用 if (pointer) 而不是 if (pointer != NULL) 吗?)
Checking for NULL pointer in C/C++(在 C/C++ 中检查空指针)
Math-like chaining of the comparison operator - as in, quot;if ( (5lt;jlt;=1) )quot;(比较运算符的数学式链接-如“if((5<j<=1)))
Difference between quot;if constexpr()quot; Vs quot;if()quot;(“if constexpr()之间的区别与“if())
C++, variable declaration in #39;if#39; expression(C++,if 表达式中的变量声明)