Solution of Linux Executable File Prompt No such file or directory

  • 2021-08-12 03:57:05
  • OfStack

Recently, I was executing an executable file using Linux operating system, and the prompt of No such file or directory appeared as a result, indicating great confusion.


./tshrf

bash: ./tshref: No such file or directory

Looking at the file information, you can see that the file exists and can be executed.


-rwxr-xr-x 1 yuan yuan 20581 4 Month  29 2004 tshref

After consulting the data, the reason is that the number of system bits does not match the number of lib library bits required for this executable file.

Print system information with uname command, and find that the system is 64-bit system


uname -a

Linux 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

Check the file information with file command and find that it is a 32-bit executable file.


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

To run 32-bit programs on 64-bit systems, you need to install the 32-bit lib library.

For Ubuntu users, use the following command to install.


sudo apt-get install ia32-libs

Reading package lists... Done
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:
 lib32z1 lib32ncurses5 lib32bz2-1.0

You may not find the library you want, but there will be several replacement packages, so choose to install one of them.


sudo apt-get install lib32bz2-1.0
lib32bz2-1.0

Then you can run the previous executable file normally.

In fact, there may be other reasons for this problem, such as the coding format of the text. This paper only puts forward one solution, and readers should analyze the same problems in detail.


Related articles: