I want to embed the Python 3.3 interpreter into Mac OS 10.9 Cocoa app to add some Python functionality. From what I've read from another StackOverflow Q&A, it would be best to create a static library (references in footer) than a dynamic library.
Here is what I've tried to create a static library (.a file) out of the Python interpreter:
- I've downloaded the Python 3.3 (CPython) source code from here.
- I've added
*static*
inside theModules/Setup.dist
file - I've entered the following to compile the source in the Terminal:
./configure LDFLAGS="-static -static-libgcc" CPPFLAGS="-static"
The result I get is the following:
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
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.
Also, I found the following in the config.log...
configure:3914: checking whether the C compiler works
configure:3936: clang -static conftest.c >&5
ld: library not found for -lcrt0.o
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Question: How can I compile Python 3.3 using Apple LLVM so I have a static library such as libpython3.3.a?
- Reference 1: Getting Python to work in Cocoa App
- Reference 2: Compile the Python interpreter statically?