繁体   English   中英

缺少Python.h头文件

[英]Python.h header missing

我正在试图弄清楚如何在C中编译Python模块( http://docs.python.org/extending/extending.html ),但似乎缺少Python.h头文件。

我已经安装了所有python开发头文件(我有Python-dev,python2.7-dev,python2.6-dev,python-all-dev)但是gcc仍在重新编译错误:

fatal error: Python.h: No such file or directory

compilation terminated.

知道我哪里错了吗? 还有一个参数我需要为Python.h添加到gcc(它是什么?)。

您需要使用python-config来确定编译时间和链接时间标志。

编译时:

gcc -c `python-config --cflags` somefile.c

链接时:

gcc -o libfoo.so -shared `python-config --ldflags`

虽然您真的应该考虑使用distutils,如使用distutils 构建C和C ++扩展中所述

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM