Why is the executable file (.exe) different from the compiled .C file?

Just out of curiosity, I wanted to know why my compiled .C files (approximately 2-5 kb) are smaller than my executable (.exe) files (130-200 kb)?

+4
source share
3 answers

The compiler source file is just the generated code from the actual source file and not much more. The executable was associated with other object files and libraries needed for all the external functions and variables that you need. This, of course, makes the executable much larger since it contains much more code.

+3
source

There can be many reasons:

  • The compiler can statically link dependent libraries that essentially copy this machine code to the resulting executable
  • The assembly often takes up more space than the source code - one line of code can be compiled into several lines of the assembly (moving data to / from registers, etc.).
+2
source

From here

DJGPP programs must bind all kinds of pmode drivers for things that normally run through the BIOS in rmode. Things like memory management, disk access, console access, hardware access, etc. Essentially, DJGPP embeds the mini-OS in your executable!

+2
source

Source: https://habr.com/ru/post/1500798/


All Articles