title: Compiler can't find Py_InitModule() .. is it deprecated and if so what should I use?
body: <p>I am attempting to write a C extension for python. With the code (below) I get the compiler warning:</p>
  
  <pre><code>implicit declaration of function ‘Py_InitModule’
  </code></pre>
  
  <p>And it fails at run time with this error:</p>
  
  <pre><code>undefined symbol: Py_InitModule
  </code></pre>
  
  <p>I have spent literally hours searching for a solution with no joy. I have tried multiple minor changes to syntax, I even found a post suggesting the method has been deprecated. However I find no replacement. </p>
  
  <p>Here is the code:</p>
  
  <pre><code>#include &lt;Python.h&gt;
  
  //a func to calc fib numbers
  int cFib(int n)
  {
      if (n&lt;2) return n;
      return cFib(n-1) + cFib(n-2);
  }
  
  
  static PyObject* fib(PyObject* self,PyObject* args)
  {
      int n;
      if (!PyArg_ParseTuple(args,"i",&amp;n)) 
          return NULL;    
      return Py_BuildValue("i",cFib(n));
  }
  
  static PyMethodDef module_methods[] = {
      {"fib",(PyCFunction) fib, METH_VARARGS,"calculates the fibonachi number"},
      {NULL,NULL,0,NULL}
  };
  
  PyMODINIT_FUNC initcModPyDem(void)
  {
      Py_InitModule("cModPyDem",module_methods,"a module");
  }
  </code></pre>
  
  <p>If it helps here is my setup.py :</p>
  
  <pre><code>from distutils.core import setup, Extension
  
  module = Extension('cModPyDem', sources=['cModPyDem.c'])
  setup(name = 'packagename', 
      version='1.0',
      description = 'a test package',
      ext_modules = [module])
  </code></pre>
  
  <p>And the test code in test.py :</p>
  
  <pre><code>import cModPyDem
  
  if __name__ == '__main__' :
  
      print(cModPyDem.fib(200))
  </code></pre>
  
  <p>Any help would be much, much appreciated.</p>