I'm learning how to extend Python in C.
Before starting, I downloaded all needed packages:
sudo apt-get install python2.7-dev
sudo apt-get install python3.5-dev
I picked up an example from internet to check if everything works fine.
Here is the link: https://docs.python.org/2/extending/extending.html
Created setup.py and built the module.
python2 setup.py build
It gave me no errors.
I created a test.py and i ran it.
it just said that the module I imported doesn't exist.
Confused i gcc'ed the C file and here is the result:
fatal error: Python.h: no such file or directory
I didn't give up and I tried this:locate Python.h
and the result was: /home/*censored*/python/include/python2.7/
so i used the flag -I and tried to GCC the code again: gcc -I /home/*censored*/python/include/python2.7/ myModule.c
The result was:
/usr/lib/gcc/x86_64-linux-gnu/6/../../../x86_64-linux-gnu/Scrt1.o: in the function "_start":(.text+0x20): reference not defined a "main"
also
myModule.c:(.text+0x37): reference not defined a "PyArg_ParseTuple"
myModule.c:(.text+0x67): reference not defined a "Py_BuildValue"
collect2: error: ld returned 1 exit status
I also downloaded the tarball and ran ./configure make and make install
but nothing, still stuck with this problem.
This is my first question on StackOverflow so be kind with me if I messed up something about text formatting. Thank you and have a good day.