Ubuntu X64运行可执行文件报错 No such file or directory

可执行文件是在Debian上编译的,拿到Ubuntu上不能运行,报如下错误

bash: ./dummysm: No such file or directory

ldd 查看依赖正常

使用readelf查看信息

readelf -a dummysm
ELF Header:
  Magic:   7f 45 4c 46 02 01 01 00 00 00 00 00 00 00 00 00 
  Class:                             ELF64
  Data:                              2's complement, little endian
  Version:                           1 (current)
  OS/ABI:                            UNIX - System V
  ABI Version:                       0
  Type:                              DYN (Shared object file)
  Machine:                           Advanced Micro Devices X86-64
  Version:                           0x1
  Entry point address:               0x1130
  Start of program headers:          64 (bytes into file)
  Start of section headers:          108176 (bytes into file)
  Flags:                             0x0
  Size of this header:               64 (bytes)
  Size of program headers:           56 (bytes)
  Number of program headers:         11
  Size of section headers:           64 (bytes)
  Number of section headers:         36
  Section header string table index: 35

Section Headers:
  [Nr] Name              Type             Address           Offset
       Size              EntSize          Flags  Link  Info  Align
  [ 0]                   NULL             0000000000000000  00000000
       0000000000000000  0000000000000000           0     0     0
  [ 1] .interp           PROGBITS         00000000000002a8  000002a8
       000000000000001a  0000000000000000   A       0     0     1
  [ 2] .note.gnu.build-i NOTE             00000000000002c4  000002c4
       0000000000000024  0000000000000000   A       0     0     4
  [ 3] .note.ABI-tag     NOTE             00000000000002e8  000002e8
       0000000000000020  0000000000000000   A       0     0     4
  [ 4] .gnu.hash         GNU_HASH         0000000000000308  00000308
       0000000000000028  0000000000000000   A       5     0     8
  [ 5] .dynsym           DYNSYM           0000000000000330  00000330
       0000000000000150  0000000000000018   A       6     1     8
  [ 6] .dynstr           STRTAB           0000000000000480  00000480
       00000000000001e1  0000000000000000   A       0     0     1
  [ 7] .gnu.version      VERSYM           0000000000000662  00000662
       000000000000001c  0000000000000002   A       5     0     2
  [ 8] .gnu.version_r    VERNEED          0000000000000680  00000680
       0000000000000040  0000000000000000   A       6     2     8
  [ 9] .rela.dyn         RELA             00000000000006c0  000006c0
       0000000000000108  0000000000000018   A       5     0     8
  [10] .rela.plt         RELA             00000000000007c8  000007c8
       0000000000000078  0000000000000018  AI       5    22     8
  [11] .init             PROGBITS         0000000000001000  00001000
       0000000000000017  0000000000000000  AX       0     0     4
  [12] .plt              PROGBITS         0000000000001020  00001020
       0000000000000060  0000000000000010  AX       0     0     16
  [13] .plt.got          PROGBITS         0000000000001080  00001080
       0000000000000008  0000000000000008  AX       0     0     8
  [14] .text             PROGBITS         0000000000001090  00001090
       0000000000000231  0000000000000000  AX       0     0     16
  [15] .fini             PROGBITS         00000000000012c4  000012c4
       0000000000000009  0000000000000000  AX       0     0     4
  [16] .rodata           PROGBITS         0000000000002000  00002000
       00000000000000bd  0000000000000000   A       0     0     8
  [17] .eh_frame_hdr     PROGBITS         00000000000020c0  000020c0
       000000000000004c  0000000000000000   A       0     0     4
  [18] .eh_frame         PROGBITS         0000000000002110  00002110
       0000000000000128  0000000000000000   A       0     0     8
  [19] .init_array       INIT_ARRAY       0000000000003d50  00002d50
       0000000000000010  0000000000000008  WA       0     0     8
  [20] .fini_array       FINI_ARRAY       0000000000003d60  00002d60
       0000000000000008  0000000000000008  WA       0     0     8
  [21] .dynamic          DYNAMIC          0000000000003d68  00002d68
       0000000000000220  0000000000000010  WA       6     0     8
  [22] .got              PROGBITS         0000000000003f88  00002f88
       0000000000000078  0000000000000008  WA       0     0     8
  [23] .data             PROGBITS         0000000000004000  00003000
       0000000000000010  0000000000000000  WA       0     0     8
  [24] .bss              NOBITS           0000000000004010  00003010
       0000000000000028  0000000000000000  WA       0     0     16
  [25] .comment          PROGBITS         0000000000000000  00003010
       0000000000000011  0000000000000001  MS       0     0     1
  [26] .debug_aranges    PROGBITS         0000000000000000  00003030
       0000000000000150  0000000000000000           0     0     16
  [27] .debug_info       PROGBITS         0000000000000000  00003180
       0000000000008d32  0000000000000000           0     0     1
  [28] .debug_abbrev     PROGBITS         0000000000000000  0000beb2
       0000000000000f7a  0000000000000000           0     0     1
  [29] .debug_line       PROGBITS         0000000000000000  0000ce2c
       0000000000001346  0000000000000000           0     0     1
  [30] .debug_str        PROGBITS         0000000000000000  0000e172
       000000000000b307  0000000000000001  MS       0     0     1
  [31] .debug_loc        PROGBITS         0000000000000000  00019479
       0000000000000418  0000000000000000           0     0     1
  [32] .debug_ranges     PROGBITS         0000000000000000  000198a0
       0000000000000160  0000000000000000           0     0     16
  [33] .symtab           SYMTAB           0000000000000000  00019a00
       00000000000007c8  0000000000000018          34    56     8
  [34] .strtab           STRTAB           0000000000000000  0001a1c8
       0000000000000370  0000000000000000           0     0     1
  [35] .shstrtab         STRTAB           0000000000000000  0001a538
       0000000000000157  0000000000000000           0     0     1
Key to Flags:
  W (write), A (alloc), X (execute), M (merge), S (strings), I (info),
  L (link order), O (extra OS processing required), G (group), T (TLS),
  C (compressed), x (unknown), o (OS specific), E (exclude),
  l (large), p (processor specific)

There are no section groups in this file.

Program Headers:
  Type           Offset             VirtAddr           PhysAddr
                 FileSiz            MemSiz              Flags  Align
  PHDR           0x0000000000000040 0x0000000000000040 0x0000000000000040
                 0x0000000000000268 0x0000000000000268  R      0x8
  INTERP         0x00000000000002a8 0x00000000000002a8 0x00000000000002a8
                 0x000000000000001a 0x000000000000001a  R      0x1
      [Requesting program interpreter: /lib/ld-linux-x86-64.so.2]
  LOAD           0x0000000000000000 0x0000000000000000 0x0000000000000000
                 0x0000000000000840 0x0000000000000840  R      0x1000
  LOAD           0x0000000000001000 0x0000000000001000 0x0000000000001000
                 0x00000000000002cd 0x00000000000002cd  R E    0x1000
  LOAD           0x0000000000002000 0x0000000000002000 0x0000000000002000
                 0x0000000000000238 0x0000000000000238  R      0x1000
  LOAD           0x0000000000002d50 0x0000000000003d50 0x0000000000003d50
                 0x00000000000002c0 0x00000000000002e8  RW     0x1000
  DYNAMIC        0x0000000000002d68 0x0000000000003d68 0x0000000000003d68
                 0x0000000000000220 0x0000000000000220  RW     0x8
  NOTE           0x00000000000002c4 0x00000000000002c4 0x00000000000002c4
                 0x0000000000000044 0x0000000000000044  R      0x4
  GNU_EH_FRAME   0x00000000000020c0 0x00000000000020c0 0x00000000000020c0
                 0x000000000000004c 0x000000000000004c  R      0x4
  GNU_STACK      0x0000000000000000 0x0000000000000000 0x0000000000000000
                 0x0000000000000000 0x0000000000000000  RW     0x10
  GNU_RELRO      0x0000000000002d50 0x0000000000003d50 0x0000000000003d50
                 0x00000000000002b0 0x00000000000002b0  R      0x1

其中有一条信息如下,Linux装载器路径如下
[Requesting program interpreter: /lib/ld-linux-x86-64.so.2]
关于装载器的信息
但去/lib下查看没有这个文件
搜索一下

sudo find / -name ld-linux-x86-64* #ls -l ld-linux-x86-64*

查找结果有以下几条

/usr/lib/x86_64-linux-gnu/ld-linux-x86-64.so.2
/usr/lib/ld-linux-x86-64.so.2
/usr/lib64/ld-linux-x86-64.so.2

切换到/lib目录下,创建软链接

sudo ln -s /usr/lib/x86_64-linux-gnu/ld-linux-x86-64.so.2 ld-linux-x86-64.so.2

问题解决。

实际上 ldd 命令已经将链接器的路径打印出来

/lib/ld-linux-x86-64.so.2 => /lib64/ld-linux-x86-64.so.2 (0x00007f9db55eb000)
librt.so.1 => /usr/lib/x86_64-linux-gnu/librt.so.1 (0x00007f9db4cd6000)
libm.so.6 => /usr/lib/x86_64-linux-gnu/libm.so.6 (0x00007f9db4b87000)

但在执行时却出了问题。

当在VScode中运行时,出现"no such file or directory"的报错。这个错误通常表示文件或目录不存在。 解决这个问题有几个方法: 1. 确保你的文件或目录的路径是正确的。检查一下文件或目录是否存在,确保路径没有拼写错误。 2. 如果你是在VScode提供的终端中运行,尝试使用Ubuntu的终端运行,而不是使用VScode提供的终端。有时候使用不同的终端可以解决这个问题。 3. 如果你在使用其他软件或插件时出现类似的问题,可以参考相关的解决方法。比如,对于POI导出Excel报错"no such file or directory"的问题,可以参考相关的解决方法来解决。 希望以上方法可以帮助你解决VScode运行报错"no such file or directory"的问题。如果问题依然存在,请进一步检查你的代码和相关环境配置。<span class="em">1</span><span class="em">2</span><span class="em">3</span> #### 引用[.reference_title] - *1* [vsCode使用npm报错: No such file or directory](https://blog.csdn.net/super_ying123/article/details/107922588)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 33.333333333333336%"] - *2* [最新:ubuntu18.04下,vscode报错:No such file or directory](https://blog.csdn.net/m0_71500261/article/details/127805958)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 33.333333333333336%"] - *3* [POI导出Excel报错No such file or directory的解决方法](https://download.csdn.net/download/weixin_38514805/12768814)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 33.333333333333336%"] [ .reference_list ]
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值