Thread: Re: [Dev-C++] GCC 3.2 (MinGW 2.0) Compiled File Sizes
Open Source C & C++ IDE for Windows
Brought to you by:
claplace
|
From: Damien <g_...@ho...> - 2003-07-12 17:55:12
|
<html><div style='background-color:'><DIV>
<P>Try adding -s to the commands when calling the compiler. The older version of Dev-C++ did that by default, making the size of your .exe files small.<BR><BR></P></DIV>
<DIV></DIV>----Original Message Follows----
<DIV></DIV>From: "Marc Heiligers" <MA...@E-...>
<DIV></DIV>To: "Dev-Cpp User's List" <DEV...@LI...>
<DIV></DIV>Subject: [Dev-C++] GCC 3.2 (MinGW 2.0) Compiled File Sizes
<DIV></DIV>Date: Sat, 12 Jul 2003 19:03:37 +0200
<DIV></DIV><mailto:dev...@li...?subject=help><mailto:dev...@li...><mailto:dev...@li...?subject=subscribe><mailto:dev...@li...?subject=unsubscribe>
<DIV></DIV>
<DIV></DIV>Hi All,
<DIV></DIV>
<DIV></DIV>I have just downloaded and installed MinGW 2.0 to upgrade my development
<DIV></DIV>environment to the latest (easily available) GCC. The installation process
<DIV></DIV>was surprisingly painless and getting it to work with Dev-Cpp was just as
<DIV></DIV>easy. Good stuff so far. But...
<DIV></DIV>
<DIV></DIV>I just wrote a command line program that does a little string manipulation
<DIV></DIV>and spits out (read as cout << (std::string)) a modified string (using the
<DIV></DIV>command line parameters as input). The complete source is less 100 lines of
<DIV></DIV>code and resides in a single file. I make use of the <IOSTREAM>and <STRING>
<DIV></DIV>headers. I compiled and found it worked perfectly, but the executable was
<DIV></DIV>468KB in size! I was expecting something more along the lines of 10KB. So I
<DIV></DIV>tried the following little program:
<DIV></DIV>
<DIV></DIV>#include <IOSTREAM>
<DIV></DIV>#include <STRING>
<DIV></DIV>
<DIV></DIV>int main(int argc, char *argv[])
<DIV></DIV>{
<DIV></DIV>std::string s = "Hello, World";
<DIV></DIV>std::cout << s;
<DIV></DIV>return 0;
<DIV></DIV>}
<DIV></DIV>
<DIV></DIV>This simple "Hello, World" demo compiles to 442KB (using default compiler
<DIV></DIV>settings, no optimization, no exception handling - and 156KB using the old
<DIV></DIV>Dev-Cpp default compiler). This is a little extreme, don't you think?
<DIV></DIV>
<DIV></DIV>So does anyone know of a way to reduce the file sizes generated by GCC 3.2?
<DIV></DIV>The only thing that springs to mind is that the template class handling of
<DIV></DIV>GCC is not that great. If we try the same demo using C-code (compiled as
<DIV></DIV>C++):
<DIV></DIV>
<DIV></DIV>#include <STDIO.H>
<DIV></DIV>
<DIV></DIV>int main(int argc, char *argv[])
<DIV></DIV>{
<DIV></DIV>char* s = "Hello, World";
<DIV></DIV>printf("%s", s);
<DIV></DIV>return 0;
<DIV></DIV>}
<DIV></DIV>
<DIV></DIV>we get a program that compiles to 21KB (and 9KB using the old Default
<DIV></DIV>Dev-Cpp compiler - even this shows a large increase in size using GCC 3.2)!
<DIV></DIV>
<DIV></DIV>Regards,
<DIV></DIV>Marc.
<DIV></DIV>
<DIV></DIV>
<DIV></DIV>
<DIV></DIV>-------------------------------------------------------
<DIV></DIV>This SF.Net email sponsored by: Parasoft
<DIV></DIV>Error proof Web apps, automate testing & more.
<DIV></DIV>Download & eval WebKing and get a free book.
<DIV></DIV>www.parasoft.com/bulletproofapps1
<DIV></DIV>_______________________________________________
<DIV></DIV>Dev-cpp-users mailing list
<DIV></DIV>Dev...@li...
<DIV></DIV>TO UNSUBSCRIBE: http://www23.brinkster.com/noicys/devcpp/ub.htm
<DIV></DIV>https://lists.sourceforge.net/lists/listinfo/dev-cpp-users
<DIV></DIV></mailto:dev...@li...?subject=unsubscribe></mailto:dev...@li...?subject=subscribe></mailto:dev...@li...></mailto:dev...@li...?subject=help></div><br clear=all><hr>MSN 8 with <a href="http://g.msn.com/8HMFEN/2740??PS=">e-mail virus protection service: </a> 2 months FREE*</html>
|
|
From: <or...@vp...> - 2003-07-12 20:04:36
|
Damien X wrote: > Try adding -s to the commands when calling the compiler. The older > version of Dev-C++ did that by default, making the size of your .exe > files small. And also you might try the -O3 or -O4 flag. Optimization also tends to make the exe file smaller. If you are still not satisfied, head on to: http://upx.sf.net ,the Ultimate Packer for eXecutables homepage. It does it's job very well, even better than commercial exe packers. Copy upx.exe into your path somewhere (so you can use it anywhere), then use "upx -9 <filename>" for best compression. Your program, that was 416 KB, after stripping (-s) and upx-ing, was reduced to 73 KB. -- Greetings, Balázs |
|
From: <sol...@ya...> - 2003-07-13 15:53:01
|
-O2 builds smaller executables than -O3 and -O4. N.B. - If you want to debug, then you have to remove -s option, since -s means strip symbols, which are needed there for debuging. Yeah, you know that, I simply warn here.. OROSZI Balázs wrote: > Damien X wrote: > >> Try adding -s to the commands when calling the compiler. The older >> version of Dev-C++ did that by default, making the size of your .exe >> files small. > > > And also you might try the -O3 or -O4 flag. Optimization also tends to > make the exe file smaller. > If you are still not satisfied, head on to: > http://upx.sf.net > ,the Ultimate Packer for eXecutables homepage. It does it's job very > well, even better than commercial exe packers. > Copy upx.exe into your path somewhere (so you can use it anywhere), > then use "upx -9 <filename>" for best compression. > > Your program, that was 416 KB, after stripping (-s) and upx-ing, was > reduced to 73 KB. > > -- > Greetings, > Balázs > > > > > ------------------------------------------------------- > This SF.Net email sponsored by: Parasoft > Error proof Web apps, automate testing & more. > Download & eval WebKing and get a free book. > www.parasoft.com/bulletproofapps1 > _______________________________________________ > Dev-cpp-users mailing list > Dev...@li... > TO UNSUBSCRIBE: http://www23.brinkster.com/noicys/devcpp/ub.htm > https://lists.sourceforge.net/lists/listinfo/dev-cpp-users > |
|
From: Marc H. <ma...@e-...> - 2003-07-18 17:02:46
|
The -s switch works much better when you add it to the Linker options (and means not having to run strip.exe on your exe). Marc -----Original Message----- From: Damien [mailto:g_...@ho...] Sent: 12 July 2003 19:55 To: ma...@e-...; dev...@li... Subject: Re: [Dev-C++] GCC 3.2 (MinGW 2.0) Compiled File Sizes Try adding -s to the commands when calling the compiler. The older version of Dev-C++ did that by default, making the size of your .exe files small. |