Solved

why empty program produces large size executable file ?

Posted on 2014-01-06
2
348 Views
Last Modified: 2014-01-07
main()
{
}

Open in new window


gcc filename.c

Why executable file is 89,886 bytes ?
0
Comment
Question by:naseeam
2 Comments
 
LVL 24

Expert Comment

by:chaau
ID: 39761199
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
 
LVL 40

Accepted Solution

by:
evilrix earned 500 total points
ID: 39761682
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

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Preface I don't like visual development tools that are supposed to write a program for me. Even if it is Xcode and I can use Interface Builder. Yes, it is a perfect tool and has helped me a lot, mainly, in the beginning, when my programs were small…
This is a short and sweet, but (hopefully) to the point article. There seems to be some fundamental misunderstanding about the function prototype for the "main" function in C and C++, more specifically what type this function should return. I see so…
The goal of this video is to provide viewers with basic examples to understand and use pointers in the C programming language.
The goal of this video is to provide viewers with basic examples to understand and use switch statements in the C programming language.

706 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now