Jump to content
  • Advertisement
Sign in to follow this  
Fred304

Why is my .exe so huge?

This topic is 4762 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I am currently developing a tetris clone and I wonder why my compiled .exe already needs 500 KB. I am using Code::Blocks with MinGW, and the ".objs" Directory contains merely 75 KB. Is that behaviour normal for a OpenGL/GLFW Application? Are there any options I can change in Code::Blocks to reduce the size of the .exe?

Share this post


Link to post
Share on other sites
Advertisement
Someone will probably give you a link to an article that'll tell you how to make it smaller.

There is a lot of bloat. Try making a simple project that's just:

#include <iostream>
void main()
{
std::cout << "Hello World" << std::endl;
}

and you'll find that it's in the half-a-meg range. There's a lot of stuff that happens before the main function that really isn't necassary for small programs. It might be necessary for your tetris clone, though.

Share this post


Link to post
Share on other sites
Maybe it's statically linking the needed libraries in the end? You're always using stuff like libc but I'm not sure how much they increase your size.

Share this post


Link to post
Share on other sites
Try passing -O3 (optimizations, can reduce code size, probably by turning off some debugging info, as well as by changing things like = vector.size() into = vector._M_size)

Also, get cygwin and run your .exe through the program "strip", which strips symbol information from the .exe - this is destructive for .DLLs, but unless you're going to be trying to treat an EXE like a DLL and link to it, you don't need no steenking symbol data.

Share this post


Link to post
Share on other sites
Quote:
Original post by MaulingMonkey
Also, get cygwin and run your .exe through the program "strip", which strips symbol information from the .exe - this is destructive for .DLLs, but unless you're going to be trying to treat an EXE like a DLL and link to it, you don't need no steenking symbol data.
strip is included as part of MinGW, so the OP may already have it. Also, with the right option strip can be run on DLLs (--strip-unneeded I think).

The reason MinGW produces such large executables, even in relese mode, is that it has to statically link against libstdc++, which is the gcc implementation of the C++ standard library. On *nix systems, gcc links dynamically to libstdc++, and MSVC links to its own C++ standard library dynamically as well. It's really a gcc + Windows problem.

Share this post


Link to post
Share on other sites
Quote:
Original post by jdhardy
Quote:
Original post by MaulingMonkey
Also, get cygwin and run your .exe through the program "strip", which strips symbol information from the .exe - this is destructive for .DLLs, but unless you're going to be trying to treat an EXE like a DLL and link to it, you don't need no steenking symbol data.
strip is included as part of MinGW, so the OP may already have it. Also, with the right option strip can be run on DLLs (--strip-unneeded I think).


Well whadya know, so it does, so it does :-).

Share this post


Link to post
Share on other sites
Thanks a lot for the strip hint, I managed to shrink my 524 KB .exe down to 270 KB with it. After applying UPX --best (and realising it also has a strip option), I am now down to 91 KB.

Share this post


Link to post
Share on other sites
Another thing to be aware of when developing C++ applications with MingW is that using the STL will add a significant amount to your executable size. See the MingW FAQ.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!