Linux 运行这个二进制文件需要哪些库?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/9467952/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-06 04:51:48  来源:igfitidea点击:

What libraries are needed for this binary to run?

linuxshared-librariesbinaryfiles

提问by Hooked

Linux-based (Ubuntu 11.10)

基于 Linux (Ubuntu 11.10)

Before my computer crashed I had a binary on my computer: ./programthat was given to me without the source. This file executed just fine. When my hard drive failed, I started with a fresh install and tried to run this binary on the same computer. It now fails with:

在我的计算机崩溃之前,我的计算机上有一个二进制文件:./program它是在没有源代码的情况下提供给我的。这个文件执行得很好。当我的硬盘驱动器出现故障时,我从全新安装开始并尝试在同一台计算机上运行这个二进制文件。它现在失败了:

bash: ./program: cannot execute binary file

Running lddon the file gives a bit more information:

ldd在文件上运行会提供更多信息:

/usr/bin/ldd: line 161: /lib64/ld-linux-x86-64.so.2: cannot execute binary file
not a dynamic executable

I have a second computer where the binary runs and lddgives the output:

我有第二台计算机运行二进制文件并ldd给出输出:

./program:
    linux-vdso.so.1 =>  (0x00007fffdad5e000)
    libz.so.1 => /lib64/libz.so.1 (0x00000039a1400000)
    libstdc++.so.6 => /usr/local/gcc/gcc-4.5.1/lib64/libstdc++.so.6 (0x00007fce82c7a000)
    libm.so.6 => /lib64/libm.so.6 (0x00007fce829f6000)
    libgcc_s.so.1 => /usr/local/gcc/gcc-4.5.1/lib64/libgcc_s.so.1 (0x00007fce827e1000)
    libc.so.6 => /lib64/libc.so.6 (0x00007fce82452000)
    /lib64/ld-linux-x86-64.so.2 (0x00007fce82f7f000)

Is there a way I can tell what is needed so I can get my program running again? I know that anything installed before the crash was done with apt-getso I don't think it requires anything unique that's not in the repository.

有什么方法可以告诉我需要什么,以便让我的程序再次运行?我知道在崩溃之前安装的任何东西都已经完成,apt-get所以我认为它不需要存储库中没有的任何独特的东西。

Localized question?

本地化问题?

I admit that this specificquestion may be particular to me - but the question still stands in the general sense. Given a binary only, how do you determine which libraries it needs to run?

我承认这个具体问题对我来说可能是特殊的——但这个问题仍然存在于一般意义上。仅给定一个二进制文件,您如何确定它需要运行哪些库?

采纳答案by Erik Ekman

Run filewith the program as argument on the computer where lddworks. It will tell you if the binary is built for 32 or 64 bits. You probably have to install the 32 bit compatibility libraries before it will run, on debian/ubuntu this is called ia32-libs.

运行file该程序的计算机,其中上争论ldd的作品。它会告诉您二进制文件是为 32 位还是 64 位构建的。您可能必须在运行之前安装 32 位兼容性库,在 debian/ubuntu 上,这称为ia32-libs.