我尝试嵌入Python 3.3,如here所述。嵌入Python 3.3
我在使用Python 2.7的MacOS 10.8,所以我从python.org下载了版本3.3的二进制发行版。从它我得到所有的标题和“Python”,我改名为“python33”,所以它不会与已安装的“Python”库相冲突。我把一切都放到一个文件夹:
embed.c /包括python33
“文件python33” 说:
python33 (for architecture i386): Mach-O dynamically linked shared library i386
python33 (for architecture x86_64): Mach-O 64-bit dynamically linked shared library x86_64
和embed.c是:
#include <Python.h>
int
main(int argc, char *argv[])
{
Py_Initialize();
PyRun_SimpleString("print 'test'\n");
Py_Finalize();
return 0;
}
但是,当我做“gcc embed.c -I./include -L。-lpython33”它打破:
ld: library not found for -lpython33
请问,有谁知道如何让它编译?
./python3.3-config - > -bash:./python3.3-config:/Library/Frameworks/Python.framework/Versions/3.3/bin/python3.3m :错误的解释器:没有这样的文件或目录 – 2013-02-21 16:43:08
在我的系统上(OS X 10.8.2,来自官方安装程序的python 3.3),它的工作方式就像一个魅力。我的输出是 -I/Library/Frameworks/Python.framework/Versions/3.3/include/python3.3m -I/Library/Frameworks/Python.framework/Versions/3.3/include/python3.3m -fno-strict-aliasing -fno-common -dynamic -DNDEBUG -g -O3 -arch i386 -arch x86_64 -L/Library/Frameworks/Python.framework/Versions/3.3/lib/python3.3/config-3.3m -ldl -framework CoreFoundation - lpython3.3m – 2013-02-21 16:59:06
我没有安装Python 3.3 - 我只是下载它并提取了主lib。当我做'gcc embed.c -I./include -ldl -framework CoreFoundation -L。 -lpython33'它仍然说“ld:找不到-lpython33的库” – 2013-02-21 17:06:14