<i id='NzMnL'><tr id='NzMnL'><dt id='NzMnL'><q id='NzMnL'><span id='NzMnL'><b id='NzMnL'><form id='NzMnL'><ins id='NzMnL'></ins><ul id='NzMnL'></ul><sub id='NzMnL'></sub></form><legend id='NzMnL'></legend><bdo id='NzMnL'><pre id='NzMnL'><center id='NzMnL'></center></pre></bdo></b><th id='NzMnL'></th></span></q></dt></tr></i><div id='NzMnL'><tfoot id='NzMnL'></tfoot><dl id='NzMnL'><fieldset id='NzMnL'></fieldset></dl></div>
          <bdo id='NzMnL'></bdo><ul id='NzMnL'></ul>
      1. <legend id='NzMnL'><style id='NzMnL'><dir id='NzMnL'><q id='NzMnL'></q></dir></style></legend>

        <small id='NzMnL'></small><noframes id='NzMnL'>

        <tfoot id='NzMnL'></tfoot>

        静态编译 Python 解释器?

        时间:2023-10-17
      2. <legend id='H4yH3'><style id='H4yH3'><dir id='H4yH3'><q id='H4yH3'></q></dir></style></legend>
          • <tfoot id='H4yH3'></tfoot>

                <tbody id='H4yH3'></tbody>

                <i id='H4yH3'><tr id='H4yH3'><dt id='H4yH3'><q id='H4yH3'><span id='H4yH3'><b id='H4yH3'><form id='H4yH3'><ins id='H4yH3'></ins><ul id='H4yH3'></ul><sub id='H4yH3'></sub></form><legend id='H4yH3'></legend><bdo id='H4yH3'><pre id='H4yH3'><center id='H4yH3'></center></pre></bdo></b><th id='H4yH3'></th></span></q></dt></tr></i><div id='H4yH3'><tfoot id='H4yH3'></tfoot><dl id='H4yH3'><fieldset id='H4yH3'></fieldset></dl></div>
                  <bdo id='H4yH3'></bdo><ul id='H4yH3'></ul>
                • <small id='H4yH3'></small><noframes id='H4yH3'>

                  本文介绍了静态编译 Python 解释器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我正在构建一个特殊用途的嵌入式 Python 解释器,并希望避免依赖动态库,所以我想用静态库编译解释器(例如 libc.a 而不是 libc.so).

                  I'm building a special-purpose embedded Python interpreter and want to avoid having dependencies on dynamic libraries so I want to compile the interpreter with static libraries instead (e.g. libc.a not libc.so).

                  我还想静态链接所有属于 Python 标准库的动态库.我知道这可以使用 Freeze.py 来完成,但是有没有替代方法可以一步完成?

                  I would also like to statically link all dynamic libraries that are part of the Python standard library. I know this can be done using Freeze.py, but is there an alternative so that it can be done in one step?

                  推荐答案

                  我发现了这个(主要是关于Python模块的静态编译):

                  I found this (mainly concerning static compilation of Python modules):

                  • http://bytes.com/groups/python/23235-build-static-python-executable-linux

                  描述用于配置的文件位于此处:

                  Which describes a file used for configuration located here:

                  <Python_Source>/Modules/Setup
                  

                  如果这个文件不存在,可以通过复制来创建:

                  If this file isn't present, it can be created by copying:

                  <Python_Source>/Modules/Setup.dist
                  

                  Setup 文件中包含大量文档,源代码中包含的 README 也提供了许多很好的编译信息.

                  The Setup file has tons of documentation in it and the README included with the source offers lots of good compilation information as well.

                  我还没有尝试编译,但我认为有了这些资源,我尝试时应该会成功.我会在这里发表我的结果作为评论.

                  I haven't tried compiling yet, but I think with these resources, I should be successful when I try. I will post my results as a comment here.

                  要获得纯静态的python可执行文件,还必须进行如下配置:

                  To get a pure-static python executable, you must also configure as follows:

                  ./configure LDFLAGS="-static -static-libgcc" CPPFLAGS="-static"
                  

                  在启用这些标志的情况下进行构建后,您可能会收到很多关于由于库不存在而重命名"的警告.这意味着您没有正确配置Modules/Setup,需要:

                  Once you build with these flags enabled, you will likely get lots of warnings about "renaming because library isn't present". This means that you have not configured Modules/Setup correctly and need to:

                  a) 添加一行(靠近顶部),如下所示:

                  a) add a single line (near the top) like this:

                  *static*
                  

                  (即星号/星号静态"和星号不带空格)

                  (that's asterisk/star the word "static" and asterisk with no spaces)

                  b) 取消注释您希望静态可用的所有模块(例如数学、数组等...)

                  b) uncomment all modules that you want to be available statically (such as math, array, etc...)

                  您可能还需要添加特定的链接器标志(如我上面发布的链接中所述).到目前为止,我的经验是这些库无需修改即可运行.

                  You may also need to add specific linker flags (as mentioned in the link I posted above). My experience so far has been that the libraries are working without modification.

                  使用以下命令运行 make 也可能会有所帮助:

                  It may also be helpful to run make with as follows:

                  make 2>&1 | grep 'renaming'
                  

                  这将显示所有由于静态链接而无法编译的模块.

                  This will show all modules that are failing to compile due to being statically linked.

                  这篇关于静态编译 Python 解释器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:C/C++ 警告:带有 BDADDR_ANY 蓝牙库的临时地址 下一篇:从 C 优雅地调用 C++

                  相关文章

                • <small id='KQl0G'></small><noframes id='KQl0G'>

                    <legend id='KQl0G'><style id='KQl0G'><dir id='KQl0G'><q id='KQl0G'></q></dir></style></legend>
                    <tfoot id='KQl0G'></tfoot>
                    • <bdo id='KQl0G'></bdo><ul id='KQl0G'></ul>

                    1. <i id='KQl0G'><tr id='KQl0G'><dt id='KQl0G'><q id='KQl0G'><span id='KQl0G'><b id='KQl0G'><form id='KQl0G'><ins id='KQl0G'></ins><ul id='KQl0G'></ul><sub id='KQl0G'></sub></form><legend id='KQl0G'></legend><bdo id='KQl0G'><pre id='KQl0G'><center id='KQl0G'></center></pre></bdo></b><th id='KQl0G'></th></span></q></dt></tr></i><div id='KQl0G'><tfoot id='KQl0G'></tfoot><dl id='KQl0G'><fieldset id='KQl0G'></fieldset></dl></div>