Ubuntu18.04可執行文件運行提示No such file or directory


參考原文見

https://blog.csdn.net/sun927/article/details/46593129?

 

最近我也遇到一個類似問題,同一個工具在Ubuntu16.04里面運行是好的,但是Ubuntu18.04運行就出錯了。

我用file也看了是32bit的應用程序,但一直沒想到Ubuntu18.04竟然默認去掉了32bit的library。

 

用uname命令打印系統信息,發現系統是64位系統

$ uname -a
Linux latitude-e5440 5.3.0-40-generic #32~18.04.1-Ubuntu SMP Mon Feb 3 14:05:59 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux

 安裝ia32-libs,提示找不到了,候選lib32ncurses5或lib32z1,我用了lib32z1.

 sudo apt-get install ia32-libs
Building dependency tree       
Reading state information... Done
Package ia32-libs is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source
However the following packages replace it:
  lib32ncurses5 lib32z1

E: Package 'ia32-libs' has no installation candidate
$ sudo apt-get install lib32z1

 另外,如果用到32bit的libstdc++6,應該是安裝

lib32stdc++6。

順便看了一下查詢用到的so,有兩種辦法

之一是ldd命令

ldd ./combine-image
	linux-gate.so.1 (0xf7f63000)
	libc.so.6 => /lib32/libc.so.6 (0xf7d71000)
	/lib/ld-linux.so.2 (0xf7f64000)

 之二是readelf -d

readelf -d  ./combine-image

Dynamic section at offset 0x7f20 contains 21 entries:
  Tag        Type                         Name/Value
 0x00000001 (NEEDED)                     Shared library: [libc.so.6]
 0x0000000c (INIT)                       0x8048880

 調用的是32bit的libc.so。

之前有部分應用不能運行估計也是這個原因。

不知道這個方法是不是可以適合WSL


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM