得到错误:bash: ./program: cannot execute binary file: Exec format error

Pow*_*rge 7 linux bash ubuntu

当我运行命令时

./program 
Run Code Online (Sandbox Code Playgroud)

我收到错误:

bash: ./program: cannot execute binary file: Exec format error
Run Code Online (Sandbox Code Playgroud)

当我运行时,uname -a我得到:

4.4.0-21-generic #37-Ubuntu SMP Mon Apr 18 18:34:49 UTC 2016 i686 i686 i686 GNU/Linux
Run Code Online (Sandbox Code Playgroud)

我还检查了有关我试图运行的程序的信息,我得到了:

ELF 64-bit LSB executable, x86-64, version 1 (GNU/Linux), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, for GNU/Linux 2.6.18, BuildID[sha1]=c154cb3d21f6bbd505d165aed3aa6ed682729441, not stripped
Run Code Online (Sandbox Code Playgroud)

/proc/cpuinfo 显示

flags       : fpuvme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe nx rdtscp lm constant_tsc arch_perfmon pebs bts xtopology nonstop_tsc aperfmperf eagerfpu pni pclmulqdq dtes64 monitor ds_cpl vmx smx est tm2 ssse3 cx16 xtpr pdcm pcid sse4_1 sse4_2 x2apic popcnt tsc_deadline_timer aes xsave avx lahf_lm epb tpr_shadow vnmi flexpriority ept vpid xsaveopt dtherm ida arat pln pts
Run Code Online (Sandbox Code Playgroud)

我怎样才能运行程序?

Ste*_*itt 17

您有一个 64 位 x86 CPU(由 中的lm标志表示/proc/cpuinfo),但您运行的是 32 位内核。您尝试运行的程序需要 64 位运行时,因此无法按原样运行。

如果您可以找到该程序的 32 位版本(或自己构建),请使用它。

或者,您可以安装 64 位内核,重新启动,然后安装程序所需的 64 位库。

要安装 64 位内核,请运行

sudo dpkg --add-architecture amd64
sudo apt-get update
sudo apt-get install linux-image-generic:amd64
Run Code Online (Sandbox Code Playgroud)

这将安装最新的 64 位 Xenial 内核以及各种支持 64 位的软件包。重新启动后,您应该会发现uname -a显示x86_64而不是i686. 如果您尝试再次运行您的程序,它可能会正常工作,或者由于缺少库而出现错误;在后一种情况下,安装相应的包(用于apt-file查找它们)以使程序运行。