Python嵌入3.3 [英] Embedding Python 3.3

查看:166
本文介绍了Python嵌入3.3的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试把Python 3.3,如所描述这里

I try to embed Python 3.3, as described here.

我在MacOS 10.8里面有Python 2.7版所以我下载的3.3版二进制分发版从python.org。从中我得到了所有我改名为python33,因此它不会与安装的蟒LIB碰撞头和蟒。我把一切都放到一个文件夹:

I'm on MacOS 10.8 which has Python 2.7 so I downloaded binary distribution of version 3.3 from python.org. From it I got all the headers and "Python" which I renamed to "python33" so it wont collide with installed "Python" lib. I put everything into a folder:

embed.c /包括python33

embed.c /include python33

文件python33说:

"file python33" says:

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。它打破了:

But when I do "gcc embed.c -I./include -L. -lpython33" it breaks with:

ld: library not found for -lpython33

请,没有人知道如何使它编译?

Please, does anyone know how to make it compile?

推荐答案

第一,formost,图书馆将在libxxx.so的形式命名,则链接将与-L找到它。 -lxxx。

First and formost, the library has to be named in the form of 'libxxx.so', then the linker will find it with '-L. -lxxx'.

即使这样,一有复制/创建不仅仅是库,但整个框架。生成的可执行文件无法正常工作

Even then, the resulting executable wont work as one has to copy/create not just the library but the whole framework.

这里更多: http://lists.apple.com /archives/cocoa-dev/2013/Feb/msg00522.html

这篇关于Python嵌入3.3的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆