我嘗試嵌入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