title: Call a Python function from within a C program
body: <p>I have an application in C and at some point I need to solve a non-linear optimization problem. Unfortunately AFAIK there are very limited resources to do that in C (please let me know otherwise). However it is quite simple to do it in Python, e.g. <a href="http://docs.scipy.org/doc/scipy-0.14.0/reference/generated/scipy.optimize.minimize.html" rel="nofollow">scipy.optimize.minimize</a>. </p>
  
  <p>While I was trying to do that I encountered some of what it seems to be very frequent pitfalls, e.g. <code>Python.h</code> not found, module not loading, segmentation fault on function call, etc.</p>
  
  <p>What is a quick and easy first-timer’s way to link the two programs?</p>