title: C++ Compiling with Python.h Undefined Symbols
body: <p>So, I've been trying to start using Python.h for a little project I want to work on that seems pretty /simple/. But before I start I want to try to learn how to use Python.h.
  So I found this little example online.</p>
  
  <pre><code>#include "Python/Python.h"  
  
  int main(int argc, char** argv)  
  {  
      Py_Initialize();  
      PyRun_SimpleString("print 'Test'");  
      PyRun_SimpleString("print str(3 + 5)"); 
      Py_Exit(0);  
  }
  </code></pre>
  
  <p>Seems pretty straight forward. When i first used</p>
  
  <pre><code>gcc test.cpp
  </code></pre>
  
  <p>to compile, i got some undefined symbols. I quickly found out I should use</p>
  
  <pre><code>-lpython2.7
  </code></pre>
  
  <p>then I found out I could also use</p>
  
  <pre><code>-L/Library/Frameworks/Python.framework/Versions/2.7/lib/
  </code></pre>
  
  <p>that didn't work (I made sure that /Library/Frameworks/Python/Versions/2.7/lib/ existed)
  I'm stuck, what do I do?
  I get</p>
  
  <pre><code>Undefined symbols:
    "_Py_Initialize", referenced from:
        _main in ccoUOSlc.o
    "_PyRun_SimpleStringFlags", referenced from:
        _main in ccoUOSlc.o
        _main in ccoUOSlc.o
    "___gxx_personality_v0", referenced from:
        _main in ccoUOSlc.o
        CIE in ccoUOSlc.o
    "_Py_Exit", referenced from:
        _main in ccoUOSlc.o
  ld: symbol(s) not found
  collect2: ld returned 1 exit status
  </code></pre>
  
  <p>EDIT:
  I just tried using the -Framework argument, and tried adding after the -L the -l python2.7 argument, and I now get</p>
  
  <pre><code>Undefined symbols:
    "___gxx_personality_v0", referenced from:
        _main in ccfvtJ4j.o
        CIE in ccfvtJ4j.o
  ld: symbol(s) not found
  collect2: ld returned 1 exit status
  </code></pre>
  
  <p>Now what?</p>