Cython与Python运行时的静态链接? [英] Cython static link with python runtime?

查看:200
本文介绍了Cython与Python运行时的静态链接?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个适用于python 2.7的Python脚本,这样说:

I have a Python script for python 2.7, say this:

print("Hello World!")

接下来,我将使用以下代码将其转换为C:

Next I turn this into C using:

python cython.py --embed helloworld.py

然后我尝试静态编译它:

And then I try to compile it statically:

gcc -IC:\Python27\include -LC:\Python27\libs helloworld.c -Wl,-Bstatic -lpython27
  -Wl,-Bdynamic

但是gcc只是创建一个使用python27.dll运行时的二进制文件.如何创建静态链接到运行时的二进制文件?

But gcc just creates a binary that uses the python27.dll runtime. How can I create a binary that statically links to the runtime?

推荐答案

如果您使用的是Linux或OS X,则可以使用我的引擎的生成器工具Schafer,具有裸"模式,它将仅静态(针对所有受支持的平台,包括Windows)构建Python,以及几个标准模块,并且还可以"cythonize"并嵌入您的来源也是如此.如果这不符合您的要求,您仍然可以从资源中获取想法你想完成什么.

If you are working from Linux or OS X, you can use my engine's builder tool, Schafer, which has a "bare" mode which will just build Python statically (for all supported platforms, including Windows), along with several standard modules, and it will also "cythonize" and embed your sources into it as well. If this doesn't fit your bill, you still can get ideas from the source on what it takes to do what you want to accomplish.

这篇关于Cython与Python运行时的静态链接?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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