Cython static link with python runtime?

和自甴很熟 提交于 2019-12-09 12:41:24

问题


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?


回答1:


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.



来源:https://stackoverflow.com/questions/8289973/cython-static-link-with-python-runtime

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!