title: Python - Py_Initialize unresolved during compilation
body: <p>I have statically compiled Python2.7 without any error. 
  To test my build, I use the following snippet: </p>
  
  <pre><code>#include "Python.h"
  int main()
  {
     Py_Initialize();
  }
  </code></pre>
  
  <p>And I am compiling it like this:</p>
  
  <pre><code>$ gcc -static -I/path/to/python/header -L/path/to/my/staticpythonlib \ 
   -lpython2.7 -ldl -l_all_other_needed_lib /tmp/my_previous_snippet.c -o myouput
  </code></pre>
  
  <p>However, an error occured. gcc claims the famous <code>undefined reference</code>.</p>
  
  <blockquote>
    <p>test.c:(.text+0x1): Undefined reference to 'Py_Initialize'</p>
  </blockquote>
  
  <p>Curiously I used gcc with the verbosity flag (I won't paste the result here) and the compiler says, it's using my libpython, but couldn't find the reference. So I listed the symbols of my static python2.7 library : </p>
  
  <pre><code>$ nm /path/to/pythonlib |grep Py_Initialize
  frozenmain.o           U Py_Initialize
  pythonrun.o  0000009e9 T Py_Initialize
  pythonrun.o  000000052 T Py_Initialize_Ex
  main.o                 U Py_Initialize
  </code></pre>
  
  <p>We can see, that <code>Py_Initialize</code> is correctly referenced in pythonrun.o. However i don't know how the compiler chose the correct object file.</p>
  
  <p>My questions are :</p>
  
  <ol>
  <li>How can I be sure, that gcc uses the correct object file in my .a lib?</li>
  <li>Is there anything wrong on my compilation options?</li>
  </ol>
  
  <p>Thanks for your help.</p>