【发布时间】:2023-01-27 01:52:28
【问题描述】:
我最近开始研究 WSL 环境。 我在 WSL 环境中编译了一个类型为“ELF 64 位 LSB 共享对象”的程序,但是当我尝试在同一环境中运行它时,它会抛出错误“无法执行二进制文件:Exec 格式错误”。
我不确定我在这里缺少什么。我怎样才能运行二进制文件。 请建议。
kshitij@APL-5CD010D2WP:~/runtime/bin$ ioc_broker &
[1] 3579
kshitij@APL-5CD010D2WP:~/runtime/bin$ bash: /bin/ioc_broker: cannot execute binary file: Exec format error
^C
[1]+ Exit 126 ioc_broker
kshitij@APL-5CD010D2WP:~/runtime/bin$ file ioc_broker
ioc_broker: ELF 64-bit LSB shared object, x86-64, version 1 (GNU/Linux), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, BuildID[sha1]=aa1e76d798d46d45f131cb53de8f947ddb4c8526, for GNU/Linux 3.2.0, not stripped
kshitij@APL-5CD010D2WP:~/runtime/bin$ uname -srv
Linux 5.10.102.1-microsoft-standard-WSL2 #1 SMP Wed Mar 2 00:30:59 UTC 2022
kshitij@APL-5CD010D2WP:~/runtime/bin$
kshitij@APL-5CD010D2WP:/mnt/d/src/myproject/build$ uname -a
Linux APL-5CD010D2WP 5.10.102.1-microsoft-standard-WSL2 #1 SMP Wed Mar 2 00:30:59 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux
我已经使用 cmake 编译了二进制文件,其中我没有指定任何关于正在使用的编译器的具体信息。
kshitij@APL-5CD010D2WP:/mnt/d/src/myproject/build$ cmake -DCMAKE_INSTALL_PREFIX=/home/kshitij/runtime ..
-- The CXX compiler identification is GNU 9.4.0
-- Check for working CXX compiler: /bin/c++
-- Check for working CXX compiler: /bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Line: 57 Using COMMON_API_VERSION 3.1.12
【问题讨论】:
-
file /lib64/ld-linux-x86-64.so.2说了什么? -
你是如何编译你的程序的?
-
kshitij@APL-5CD010D2WP:~$ 文件 /lib64/ld-linux-x86-64.so.2 /lib64/ld-linux-x86-64.so.2: 到 /lib/x86_64-linux-gnu/ 的符号链接ld-2.31.so kshitij@APL-5CD010D2WP:~$ file /lib/x86_64-linux-gnu/ld-2.31.so /lib/x86_64-linux-gnu/ld-2.31.so: ELF 64 位 LSB 共享对象, x86-64, 版本 1 (SYSV), 动态链接, BuildID[sha1]=4587364908de169dec62ffa538170118c1c3a078, 剥离
标签: linux ubuntu windows-subsystem-for-linux compatibility elf