【发布时间】:2012-06-12 07:49:10
【问题描述】:
我的 C 代码:
#include<stdio.h>
#include "Python.h"
int main()
{
printf("Hello World");
return 0;
}
我为 python2.7 安装了python-dev。此外,Python.h 在/usr/include/python2.7 中可用。
gcc myfile.c#Python.h: 没有这样的文件或目录
我什至尝试过:
gcc -L/usr/include/python2.7/ myfile.c#Python.h: 没有这样的文件或目录
我尝试使用使用Python.h 的pip 构建python c 模块ujson,它能够编译。
我错过了什么/做错了什么?
【问题讨论】:
-
使用 -I 代替 -L,更好的解决方案:编写一个 makefile(是的,这需要一些研究,但努力是值得的)。在命令行上编译可能会很痛苦
-
如果此代码是 Python 扩展,那就更好了:编写一个
setup.py文件并使用 distutils。
标签: python c gcc include include-path