我只是编写了一个简单的C可执行文件来检查其是否Python.h
正常工作
#include<Python.h>
#include<stdio.h>
int main()
{
printf("this is a python header file included programm\n");
return 0;
}
显然,它并没有太大作用。但是,当我尝试使用gcc
它进行编译时,出现了一个错误:
foo.c:1:19: fatal error: Python.h: No such file or directory.
然后,我检查了python-dev软件包是否已Python.h
安装或未使用locate
。
$locate Python.h
/usr/include/python2.7/Python.h
对我来说很明显,Python.h
我的系统上有头文件。如何使我的可执行文件正常工作?
您需要限定包含
#include <python2.7/Python.h>
或告诉gcc在哪里可以找到Python.h
gcc -I /usr/include/python2.7/ program.c
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句