|
From: Daniel K. O. <dan...@ya...> - 2003-10-03 15:00:47
|
Just to add...
The C++ programs get bigger cause they use static C++ libraries, as it
was not feasible to make MinGW work with Microsoft's C++ Runtime
library. MinGW users decided they didn't want to ship a DLL for their
C++ programs, so it gets linked staticaly. (but I don't know if the
latest MinGW 3.1 has an option to compile it dimamically, with a
separated DLL)
About what Zelst wrote, could you please tell why stripping (with the -s
linker flag) is not recommended?
And about the PrintCpp.exe... damn, 1 MB for a hello world? You probably
activated the debug info. Try disabling it, setting an optimization
level, and adding the -s to the linker flags. Here it compiled with 209 KB.
AND last, but not least, a request for the Devs: add a button in the
compile window saying: "Wanna reduce your exe's size? Click here", and
popup the tip-of-the-day window with those explanations.
Daniel K. O.
P.D. van Zelst wrote:
>First off: The C++ code you used is evil and non-standard. ".h" for C++
>standard headers are deprecated (should not be used anymore, have been
>replaced by something better)... use the extensionless headers instead. Like
>"#include <iomanip>".
>
>And now for the filesize matter: Who gives a ***. This issue has come up way
>too many times now. If you're so concerned about the executable size, either
>avoid using the iostreams library altogether, strip your executables after
>compiling (not recommended), use an executable packing program, or wait for
>the new GCC release (which is said to have shorter compile times and
>generates smaller executables). The initial size difference does not scale.
>Huge software projects using thousands of lines of code do not become
>linearly larger. The few hundred kilobytes that get added to the executable
>are caused by the iostreams library implementation. This is a one-time size
>increase... when your applications become larger, you'll see that the size
>doesn't increase much more after that. Comparing executable sizes based on
>trivial "Hello World" applications is a bad idea.
>
>Regards,
>
>
>Paul
>
>-----Original Message-----
>From: dev...@li...
>[mailto:dev...@li...] On Behalf Of Roger
>Chrispim
>Sent: Friday, October 03, 2003 3:11 PM
>To: dev...@li...
>Subject: [Dev-C++] exe file size
>
>Dear sir,
>
>I wrote some programs using Dev-C++ using C coding and C++ coding. I realize
>a too big difference between the size generated by each coding way. Is there
>a way to generate smaller executable C++ files. Bellow, there is an example
>showing this:
>
>Example using C:
>#include <stdio.h>
>#include <stdlib.h>
>main()
>{
> printf("\nHello\n");
>}
>
>The size of the generated by Dev-C++ PrintC.exe file is 27,856 bytes.
>
>Example using C++:
>#include <iomanip.h>
>main()
>{
> cout << endl << "Hello" << endl;
>}
>
>The size of the generated by Dev-C++ PrintCpp.exe file is 1,268,542 bytes.
>
>Thank you for your help
>
>Roger
>
>
>
|