標籤:linux uname file ubuntu
最近在使用Linux作業系統執行一個可執行檔,結果出現了No such file or directory的提示,表示很疑惑。
./tshrfbash: ./tshref: No such file or directory
查看檔案資訊,可以看到檔案是存在的,並且是可以執行的。
-rwxr-xr-x 1 yuan yuan 20581 4月 29 2004 tshref
查閱資料後,原因是系統位元與該可執行檔需要的lib庫位元不匹配。
用uname命令列印系統資訊,發現系統是64位系統
uname -aLinux yuan-vm 3.13.0-32-generic #57-Ubuntu SMP Tue Jul 15 03:51:08 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux
用file命令查看檔案資訊,發現是一個32位可執行檔。
file ./tshref./tshref: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.2.5, not stripped
要想在64位系統上與運行32位程式,則需要安裝32位lib庫。
對於Ubuntu使用者可以使用下面的命令安裝。
sudo apt-get install ia32-libsReading package lists... DoneBuilding dependency tree Reading state information... DonePackage ia32-libs is not available, but is referred to by another package.This may mean that the package is missing, has been obsoleted, oris only available from another sourceHowever the following packages replace it: lib32z1 lib32ncurses5 lib32bz2-1.0
過程中有可能找不到需要的庫,但是會有幾個替代包,選擇安裝其中一個。
sudo apt-get install lib32bz2-1.0lib32bz2-1.0
然後就可以正常運行之前的可執行檔了。
遇到這種問題其實還有可能是其他原因,例如文本的編碼格式問題等,本文僅提出了一種解決方案,讀者遇到相同問題要具體問題具體分析。
Linux執行可執行檔提示No such file or directory的解決方案