1.8k views
3 votes
Explain the difference between an object file and an executable file.

User Yava
by
6.0k points

1 Answer

3 votes

Answer:

Object file:

  • Object file has the object code.
  • The source code, which is a program written by the programmer is compiled, is converted to an intermediate code which is called an object code.
  • So object file is a file produced by the compiler or interpreter.
  • The compiler eliminates the errors such as syntax errors from the source code and then converts this code to an object file which lies in the middle of source code and executable file because the CPU cannot execute an object file directly.
  • Object file has an extension of .o in Linux and .obj in Windows and it object file is also called relocatable file and it contains data, code and information such as debugging information. This file is put into a special format to send to the linker in order to create an executable file.

Executable file

  • The object code that is produced by the compiler is then sent to the linker to generate the executable file.
  • This is also called the final file that is executed and used to give the output of the program instructions.
  • It has an extension of .exe
  • Executable file is machine understandable.
  • It is created by linking the the object files by the linker. The object files are linked using a linker which integrates the object files to produce an executable file.
  • It is an executable file which is loaded into the memory when the program is to be run and the executable code is executed by the CPU directly.
User Hank
by
5.5k points