[英]Python.h header missing
I'm trying to figure out how to compile Python modules in C ( http://docs.python.org/extending/extending.html ), but the Python.h header file appears to be missing. 我正在试图弄清楚如何在C中编译Python模块( http://docs.python.org/extending/extending.html ),但似乎缺少Python.h头文件。
I've installed all the python development headers (I have Python-dev, python2.7-dev, python2.6-dev, python-all-dev) but gcc is still reutrning the error: 我已经安装了所有python开发头文件(我有Python-dev,python2.7-dev,python2.6-dev,python-all-dev)但是gcc仍在重新编译错误:
fatal error: Python.h: No such file or directory
compilation terminated.
Any idea where I'm going wrong here? 知道我哪里错了吗? Also is there an argument I need to add to gcc for Python.h (and what is it?). 还有一个参数我需要为Python.h添加到gcc(它是什么?)。
You need to use python-config
to determine the compile time and link time flags. 您需要使用python-config
来确定编译时间和链接时间标志。
When compiling: 编译时:
gcc -c `python-config --cflags` somefile.c
When linking: 链接时:
gcc -o libfoo.so -shared `python-config --ldflags`
Though you really ought to think about using distutils as described in Building C and C++ Extensions with distutils 虽然您真的应该考虑使用distutils,如使用distutils 构建C和C ++扩展中所述
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.