I am reading about libraries in C but I have not found yet an explanation on what an object file is. What's the real difference between any other compiled file and an object file? Would be glad if someone could explain in human language. :)
An object file is the real output from the compilation phase. It's mostly machine code, but has info that allows a linker to see what symbols are in it as well as symbols it requires in order to work. (For reference, "symbols" are basically names of global objects, functions, etc.)
A linker takes all these object files and combines them to form one executable (assuming that it can, ie: that there aren't any duplicate or undefined symbols). A lot of compilers will do this for you (read: they run the linker on their own) if you don't tell them to "just compile" using command-line options. (
Here's a typical high level flow for this process for code in High Level Language such as C
--> goes through pre-processor
--> to give optimized code, still in C
--> goes through compiler
--> to give assembly code
--> goes through an assembler
--> to give code in machine language which is stored in OBJECT FILES
--> goes through Linker
--> to get an executable file.
This flow can have some variations for example most compilers can directly generate the machine language code, without going through an assembler. Similarly, they can do the pre-processing for you. Still, it is nice to break up the constituents for a better understanding.
An object file is just what you get when you compile one (or several) source file(s).
It can be either a fully completed executable or library, or intermediate files.
The object files typically contain native code, linker information, debugging symbols and so forth.
Object code are codes tat are dependent on functions, symbols, text to run the machine. Just like old telex machines which required teletyping to send signals to other telex machine. In the same way processor requires binary code to run machine. Object file is like binary code but is not linked. Linking creates additional files so that user does not have to have compiler like c language. User can directly open the exe file once the object file is linked with some compiler like c language , or vb etc.