Sign in to follow this  
edwinnie

compiled sizes

Recommended Posts

hey! jus wondering abt this though, i noticed that after compiling my program in debug mode, the .exe output is like 1.55 mb. So i was wondering how do these published games or other programs have such small .exe files like eg 200kb... i understand i am compiling in debug mode though, but release mode alone probably wont solve this problem, so there must be something else i am missing out... thx!

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
if you use dll's you can get your exe size down

Share this post


Link to post
Share on other sites
Quote:
Original post by edwinnie
i understand i am compiling in debug mode though, but release mode alone probably wont solve this problem, so there must be something else i am missing out...

thx!
Why not compile it in release mode, It's so easy to do! You'll in fact find that your exe is way smaller in release build.

Please remember to try everything you can reasonably try before posting, including using Google. That goes for everyone.

Share this post


Link to post
Share on other sites
Quote:
Original post by edwinnie
i understand i am compiling in debug mode though, but release mode alone probably wont solve this problem, so there must be something else i am missing out...


You'd be surprsed then.
Debug mode carries around ALOT of baggage and unoptimised code so that the debugger can do its job.
To compare and contrast, i've got a test program which in debug mode comes in at 1.98meg and in release mode at 800k, thats a difference of over half and that program is statically linking with the runtime, if I was to change it to dynamic linkage it would probably shrink the exe even more (however over all it would probably be bigger as the dlls themselves would have to be transported about and could include code I dont need), as shown by another project which is using the MT-DLL runtime and has a debug size of 520K and a release size of 212K, but requires a dll of 242k to function. (and its still statically linking some stuff as my windowing framework must be statically linked)

Share this post


Link to post
Share on other sites
And at least for gcc, bumping optimizations to O3 [full] usually halves the binary size again over the non-optimized version [at least for the STL heavy examples I've run].

Share this post


Link to post
Share on other sites
Both the Visual C++ and GCC compiler allow you to optimise for size over speed whih can shrink the end file size down a bit. If your using VS then linking against the DLL version of the C runtime library can have a significant impact on the .exe/.dll size, most computers now will have the msvcrtxx.dll present on their system so you probably won't have to distribute it with your application. If your using GCC then running strip on the end file is also another option which again can have a significant effect on filesize.

Of course, there's always UPX for compressing the file, you can usually get between 30-50% compression using this tool I've found.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this