简体   繁体   English

在其他Linux计算机上运行已编译的Linux可执行文件

[英]Running compiled Linux executable on other Linux computers

I've been working on a custom program that allows me to control my other Linux-based computers on my network. 我一直在研究一个自定义程序,该程序使我可以控制网络上的其他基于Linux的计算机。 I've been using Python and used PyInstaller to compile the code into a Linux executable. 我一直在使用Python,并使用PyInstaller将代码编译成Linux可执行文件。 Running the executable on my own computer works just fine and does exactly what it's supposed to. 在我自己的计算机上运行可执行文件可以正常工作,并且完全可以达到预期的效果。 But once I send it over to another computer to test it, I get this error. 但是,一旦将其发送到另一台计算机进行测试,就会收到此错误。

ImportError: /lib/x86_64-linux-gnu/libc.so.6: version 'GLIBC_2.25' not found (required by /tmp/_MEIXcUz91/libudev.so.1)
[3716] Failed to execute script RP

And the command I used to compile the code with PyInstaller 还有我用来使用PyInstaller编译代码的命令

python pyinstaller.py -D -F -n RP -c RP.py

Again, the executable runs perfectly on the computer I used to create and compile it, but once I send it over to my other Linux-based computer and execute it, it crashes. 同样,可执行文件可以在我用来创建和编译它的计算机上完美运行,但是一旦将其发送到另一台基于Linux的计算机上并执行它,它就会崩溃。

The problem is that you have different C system libraries on the two machines. 问题是您在两台计算机上有不同的C系统库。 There can sometimes be difficulties when porting a pre-built binary. 移植预构建的二进制文件有时会遇到困难。 Either you ensure that you're using a similar environment or you put all dependencies into the binary - this may increase its size significantly. 确保您使用的是类似环境,或者将所有依赖项放入二进制文件中-这可能会大大增加二进制文件的大小。 To do the latter you need to use the ´--static´ keyword during compilation. 为此,您需要在编译过程中使用“ --static”关键字。 I'm not sure, though, whether this is enough. 不过,我不确定这是否足够。

EDIT: 编辑:

Since this is a pure Python project, you should make sure that the used Python version is compatible, ie, same Python version and also the same Python build (CPython, etc.). 由于这是一个纯Python项目,因此应确保所使用的Python版本兼容,即,相同的Python版本以及相同的Python构建(CPython等)。

use ldd if you file is RP ldd RP - looking for dynamice so libraries used by the executable if you can change the linking of your program to static libraries, may be able to make more portable else you will have to stay on same release of linux to run your program. 如果您的文件是RP,请使用ldd ldd RP-寻找动态,以便可执行文件使用的库(如果您可以将程序链接更改为静态库),则可以使其具有更高的可移植性,否则您将不得不使用相同版本的linux运行您的程序。 You could also package the .so dependencies with your executable,but messy. 您还可以将.so依赖项与可执行文件打包在一起,但是很混乱。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM