Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I compiled a small "hello world" C program on Ubuntu 10.04 32 bit machine. Then I put the executable(a.out) on Ubuntu 12.10(64 bit) VMWare virtual machine and tried to execute it(./a.out). The OS does not identify the file and says 'No such file or directory'. But when I put the same executable on a Ubuntu 12.10(64 bit) running on a 64 bit laptop, it runs fine and I get the desired output. The VM is running on IBM Blade Servers. I wanted to know why the results for a VM?

share|improve this question

2 Answers 2

up vote 15 down vote accepted
+50

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:

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.

share|improve this answer
2  
This "No file found" error message confused me too the first time °͜°, then I understood it meant some file required by the app was missing. –  Ramchandra Apte Oct 9 '13 at 2:55

You might be able to see what it's trying to load using strace (program).

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.