• C

why empty program produces large size executable file ?

main()
{
}

Open in new window


gcc filename.c

Why executable file is 89,886 bytes ?
LVL 1
naseeamAsked:
Who is Participating?
 
evilrixConnect With a Mentor Senior Software Engineer (Avast)Commented:
Your program isn't just the code you write, it also includes the C/C++ runtime framework. This is the bootstrap code that sets up the process environment, executes your entry point function (main) and, when main finishes, cleans up the process before terminating it. This all happens behind the scenes but is additional code added by the compiler.

>> I think you have forgotten to link your object code. Try adding
By default, the compiler will generate an executable called a.out. Whilst is it certainly a good idea to add a flag to create a named binary it is not mandatory.
0
 
chaauCommented:
I think you have forgotten to link your object code. Try adding
-o myprogram

Open in new window

at the end of your command line and see what is being produced
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.