[C++] Gigantic output

Started by
7 comments, last by Decrius 14 years, 1 month ago
I've a project with a 7MB static library output. Executables that link to my library end up around 1MB. I tried to break things down a bit, but it didn't end well. I've done everything I could to shrink this monster in vain. I only depend on D3D(x)9, some STL containers and the WinAPI. Here's what I've done. - VC_EXTRALEAN - Used precompiled headers - Reduced template instantiations. (Each removal means a bunch of code to change) - Inlined only a few things - Split up projects (One 7MB library became 4 3MB ones) Please inform me of any other action I can add to that list short of tearing everything down. This is one of those "too big to fail" deals for me.
Advertisement
7MB static library output doesn't sound so bad. Remember, the compiler can't go about optimizing the code too much, since it doesn't know what code you are using and what code you aren't. It'd be perfectly valid to pick some random, non-static function and use it in your linked code.
What you should be worrying about is the compile settings on the projects that link the library, because those are the projects that will be optimizing the code. Make sure to turn on full program optimizations, and optimize for size.
Really? That's a relief. Even so, I'm not as well versed with the linker as I'd like to be. Is there more I need to know outside of it's command line options/property pages?
Not really. Even though the static lib is 7MB, the final EXE should be much less. Just make sure "Eliminated Unreferenced Symbols" or whatever it's called is on. I think it's on by default.
Also turn on LTCG (Link-time code generation) for release builds.
Alright! Well, thanks much!
Quote:This is one of those "too big to fail" deals for me.


You're getting bailed out by government to keep your lib going? Where can I apply for that?
Quote:You're getting bailed out by government to keep your lib going? Where can I apply for that?


You couldn't resist, could you? [disturbed]
7MB? Seriously? Some of the Boost libs approach 100MB, and I've never run into any particular issues with them.

Wielder of the Sacred Wands
[Work - ArenaNet] [Epoch Language] [Scribblings]

My lib is about 3 MB, at first I thought it was gigantic as well, but with C++ files are always bulky. Just multiply what you'd expect from a C application's size by 10, and you get a rough estimate what is reasonable for C++...

And yes, static linking FTW :)
[size="2"]SignatureShuffle: [size="2"]Random signature images on fora

This topic is closed to new replies.

Advertisement