Unable to run a 32-bit program on 64-bit VM
Solution 1:
The message No such file or directory
does not refer to your executable file: a.out
. Instead it refers to a helper program that’s needed to run the 32 bit dynamically linked executable a.out
.
Now, I found all of these very well explained in this nice article:
- About running 32 bit programs on 64 bit Ubuntu and shared libraries
Static and dynamic linkage
There are two types of binary executables: statically linked and dynamically linked ones. First about the statically linked ones: When a program wants to call a library function, it refers to it by name. When building the program from source, all library functions used in the program are copied from the library into the program. The program then contains its own code as well as the code of the library functions it uses. Then in the calling places the name is changed to the address of the corresponding function in the program. This process is called linking because it links together the name of a function with the function itself, its implementation. It’s called static, because the link cannot be changed after the program has been built.
Dynamically linked programs work differently: The program also refers to library functions by name. When building the program, two lists are assembled and stored together with the program: a list of which library functions are used in which places, and a list of the libraries that contain the functions used by the program. That’s all for building the program.
Later, at execution time, a special helper program, the so-called dynamic linker, looks in specific places in the file system for each library on the library list and loads it into memory. Now the dynamic linker knows at what memory addresses the library functions are available. It uses the first list to write the correct address in all places that call library functions. Then the dynamically linked program can be run.