我想将Python 3.3解释器嵌入到Mac OS 10.9 Cocoa 应用程序中以添加一些 Python 功能。从我从另一个 StackOverflow 问答中读到的内容,最好创建一个静态库(页脚中的引用)而不是动态库。
这是我尝试从 Python 解释器创建静态库(.a 文件)的内容:
- 我已经从这里下载了 Python 3.3 (CPython) 源代码。
- 我已经
*static*
在Modules/Setup.dist
文件中添加了 - 我输入了以下内容来编译终端中的源代码:
./configure LDFLAGS="-static -static-libgcc" CPPFLAGS="-static"
我得到的结果如下:
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
我的理解是,gcc 实际上在 Mavericks 中被 Apple LLVM 5.0 版(clang-500.2.79)(基于 LLVM 3.3svn)所取代。
另外,我在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)
问题:如何使用Apple LLVM编译 Python 3.3,以便拥有一个静态库,例如libpython3.3.a?
- 参考1: 让Python在Cocoa App中工作
- 参考2: 静态编译Python解释器?