Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

gcc : Unable to find Python.h, When its there in /usr/includes/python2.7?

My C code:

#include<stdio.h>
#include "Python.h"

int main()
{
    printf("Hello World");
    return 0;
}

I have python-dev installed for python2.7. Moreover, Python.h is available in /usr/include/python2.7.

gcc myfile.c # Python.h: No such file or directory

I even tried : gcc -L/usr/include/python2.7/ myfile.c # Python.h: No such file or directory

I tried building a python c module ujson with pip that uses Python.h, it was able to compile.

What am I missing / doing wrong ?

like image 382
Yugal Jindle Avatar asked Dec 27 '22 23:12

Yugal Jindle


1 Answers

It should be -I, not -L:

gcc -I/usr/include/python2.7 myfile.c
like image 153
mata Avatar answered Dec 29 '22 16:12

mata