Code::Blocks Forums

User forums => Help => Topic started by: phlox81 on June 13, 2005, 09:02:35 pm

Title: compiled files: size
Post by: phlox81 on June 13, 2005, 09:02:35 pm
I downloaded Code::Blocks a few days ago, and gotta say, good work guys :) :D

I installed the C::B Version which also brings a mingw compiler along, since
i only have an old MSVC 6...

So, now i startet playing around with some files, and also installed boost.
I was playing a little with boost::filesystem, but than wondered why my
executable was 2 MB big. So, i used the wrong library (debug).
With the normal boost::filesystem library the excutable is just 570 k,
which still is a bit big for a small programm, which only purpose it is
to test some code & compiling.
Then i created a Hello World Project, to see what a 'normal' Hello World
would compile to. Still 470 K.
I started then my old MSVC and copyied the project to it.
Result: Debug Version : 510 Kb, Release: 96Kb.

So, my question is, how can i make the Mingw make a smaller excutable
than now (if its gonna be better than 96 is not so important *g*), but smaller
than 470 would be quite good.
Can i do this by configuring the compiler options in C::B, or how could I achive that ?

Devil
Title: compiled files: size
Post by: phlox81 on June 13, 2005, 09:23:29 pm
Ok, i found now the Linker Options tab in Compiler Options, and added -s there,
brings in total a filesize of 263, which is for a hello world still a bit big, is less possible ?
Title: compiled files: size
Post by: polygon7 on June 13, 2005, 09:26:28 pm
Hi,
try to use "-s" compiler (or linker - i dont remember - i use msvc) option,
or "Strip" utility (strip --strip-all). You could merge sections and realign exe, too. Article about reducing exe size: http://www.catch22.net/tuts/minexe.asp :)
Title: compiled files: size
Post by: mandrav on June 13, 2005, 10:13:13 pm
You might want to take a look at this (http://www.codeblocks.org/index.php?name=PNphpBB2&file=viewtopic&t=254) thread.

Yiannis.
Title: compiled files: size
Post by: phlox81 on June 13, 2005, 10:58:38 pm
Quote from: mandrav
You might want to take a look at this (http://www.codeblocks.org/index.php?name=PNphpBB2&file=viewtopic&t=254) thread.


how could i add a call to strip each time a exe file is getting compiled ?

Devil
Title: compiled files: size
Post by: rickg22 on June 13, 2005, 11:48:43 pm
post-compilation steps, "strip myfile.exe" in your project options. Oh you might like also using UPX, an executable compressor. Also, take in mind that using the stream libraries adds a lot of size to your executable. Using basic i/o (i.e. printf) reduces it a lot.