title: Mavericks: Compile Python Interpreter into a static lib
body: <p>I want to embed the <strong>Python 3.3</strong> interpreter into <strong>Mac OS 10.9</strong> Cocoa app to add some Python functionality. From what I've read from another StackOverflow Q&amp;A, it would be best to create a static library (references in footer) than a dynamic library.</p>
  
  <p>Here is what I've tried to create a static library (.a file) out of the Python interpreter:</p>
  
  <ol>
  <li>I've downloaded the Python 3.3 (CPython) source code from <a href="http://www.python.org/download/releases/3.3.4/" rel="nofollow noreferrer">here</a>.</li>
  <li>I've added <code>*static*</code> inside the <code>Modules/Setup.dist</code> file</li>
  <li>I've entered the following to compile the source in the Terminal:
  
  <ul>
  <li><code>./configure LDFLAGS="-static -static-libgcc" CPPFLAGS="-static"</code></li>
  </ul></li>
  </ol>
  
  <p>The result I get is the following:</p>
  
  <pre><code>checking build system type... x86_64-apple-darwin13.1.0
  checking host system type... x86_64-apple-darwin13.1.0
  checking for --enable-universalsdk... no
  checking for --with-universal-archs... 32-bit
  checking MACHDEP... darwin
  checking for --without-gcc... no
  Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/usr/include/c++/4.2.1
  checking for gcc... gcc
  checking whether the C compiler works... no
  configure: error: in `/Path/To/My/Source/Python-3.3.4':
  configure: error: C compiler cannot create executables
  See `config.log' for more details
  </code></pre>
  
  <p>My understanding is that gcc is actually replaced by Apple LLVM version 5.0 (clang-500.2.79) (based on LLVM 3.3svn) in Mavericks. </p>
  
  <p>Also, I found the following in the <strong>config.log</strong>...</p>
  
  <pre><code>configure:3914: checking whether the C compiler works
  configure:3936: clang  -static  conftest.c  &gt;&amp;5
  ld: library not found for -lcrt0.o
  clang: error: linker command failed with exit code 1 (use -v to see invocation)
  </code></pre>
  
  <p><strong><em>Question:</em></strong> How can I compile Python 3.3 using <strong>Apple LLVM</strong> so I have a static library such as <em>libpython3.3.a</em>?</p>
  
  <hr>
  
  <ul>
  <li>Reference 1:
  <a href="https://stackoverflow.com/questions/21624324/getting-python-to-work-in-cocoa-app">Getting Python to work in Cocoa App</a></li>
  <li>Reference 2:
  <a href="https://stackoverflow.com/questions/1150373/compile-the-python-interpreter-statically">Compile the Python interpreter statically?</a></li>
  </ul>