Tyl*_*r K 2 linux ubuntu gcc alpine-linux
我在 alpine linux 容器内编译了一个简单的 hello world C 程序,并将其复制到我的 ubuntu 主机上。令我惊讶的是,我无法在我的 ubuntu 主机上运行二进制文件。相反,当我尝试执行程序时出现以下错误。
$ /bin/bash ./hello
$ ./hello: ./hello: cannot execute binary file
Run Code Online (Sandbox Code Playgroud)
为什么我不能在 ubuntu 上运行我在 alpine 上编译的程序?
更新 我犯了一个错误,试图将 C 程序作为 bash 脚本运行。然而,在纠正我的错误后,我仍然得到一个错误......
$ ./hello
$ bash: ./hello: No such file or directory
Run Code Online (Sandbox Code Playgroud)
我已经使二进制可执行文件,所以这不应该是问题。运行在主机上编译的相同程序时不会显示此错误消息。
更新 让我澄清几点。
hello: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/l, for GNU/Linux 3.2.0, BuildID[sha1]=bc9e3e2ecfc026f8077dca28dbbdee4778862d7a, not stripped
Run Code Online (Sandbox Code Playgroud)
linux-vdso.so.1 (0x00007ffdbc79e000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f517b5ae000)
/lib64/ld-linux-x86-64.so.2 (0x00007f517bba1000)
Run Code Online (Sandbox Code Playgroud)
hello: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib/ld-, with debug_info, not stripped
Run Code Online (Sandbox Code Playgroud)
linux-vdso.so.1 (0x00007ffec27f7000)
libc.musl-x86_64.so.1 => not found
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1660 次 |
| 最近记录: |