英文:
Creating a standalone linux exe from Python code
问题
我们正在尝试创建一个单独的可执行文件版本,该版本可以在Ubuntu 16.x到22.x以及RedHat 7.2上运行我们的Python应用程序。
目前,我们正在使用两步骤的过程在Ubuntu 22.04上构建:
- 使用PyInstaller创建一个单一的可执行文件(其中包括捆绑我们的应用程序使用的一些其他二进制工具)。
- 使用staticx来静态链接可执行文件使用的所有库。
然而,我们遇到了问题。例如,在Ubuntu 16.04上运行并生成二进制工具时,我们会收到如下错误:
/lib/x86_64-linux-gnu/libc.so.6: 找不到版本 'GLIBC_2.34'(由 /tmp/_MEIvDsZl/libgcc_s.so.1 要求)
因此,二进制工具正在使用由staticx捆绑的libgcc_s.so.1,但它需要一个不存在的libc.so.6。
我尝试过使用staticx的-l参数将libc.so.6从构建机器添加进去,但似乎没有任何改善。
所以:
- 有人知道如何使staticx生成在这种情况下能够工作的可执行文件吗?
- 有没有替代staticx的方法,可以生成适用于所有操作系统的可执行文件,包括捆绑和生成二进制工具?
英文:
We are trying to create a single standalone exe version of our Python application which will run on Ubuntu versions 16.x to 22.x and also on RedHat 7.2.
Currently we're building on Ubuntu 22.04 using a two step process
- PyInstaller to make a single exe (this includes bundling some other binary tools that our app uses)
- staticx to statically link all libraries that the exe uses.
However we are seeing problems. E.g. when running on Ubuntu 16.04 and spawning the binary tools, we get errors like:
/lib/x86_64-linux-gnu/libc.so.6: version 'GLIBC_2.34' not found (required by /tmp/_MEIvDsZl/libgcc_s.so.1)
So the binary tool is using the libgcc_s.so.1 bundled by staticx but then it requires a libc.so.6 that doesn't exist.
I've tried adding the libc.so.6 from the build machine using staticx's -l argument but that seems to make no difference.
So
- Does anyone know how we can get staticx to produce an exe that will work in this situation?
- Are there any alternatives to staticx that will produce an exe that will work for all our OSs, including bundling and spawning the binary tools?
答案1
得分: 0
这似乎更多是与PyInstaller相关,而不是StaticX(尽管我们仅使用PyInstaller时从未遇到问题)。这解决了问题:
英文:
It seems that the problem is more an issue with PyInstaller than StaticX (though we never had a problem when just using PyInstaller). This solves the problem:
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论