Cython 与 python 运行时静态链接?
我有一个用于 python 2.7 的 Python 脚本,这样说:
print("Hello World!")
接下来我使用以下方法将其转换为 C:
python cython.py --embed helloworld.py
然后我尝试静态编译它:
gcc -IC:\Python27\include -LC:\Python27\libs helloworld.c -Wl,-Bstatic -lpython27
-Wl,-Bdynamic
但 gcc 只是创建一个使用 python27.dll 运行时的二进制文件。如何创建静态链接到运行时的二进制文件?
I have a Python script for python 2.7, say this:
print("Hello World!")
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
But gcc just creates a binary that uses the python27.dll runtime. How can I create a binary that statically links to the runtime?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您使用 Linux 或 OS X,则可以使用我的引擎构建工具 Schafer,它有一个“裸”模式,它将仅静态构建 Python(适用于所有受支持的平台,包括 Windows)以及几个标准模块,并且它还将“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.