![]() |
HELP!!!!!!!!
i'm using DEV_CPP and i am getting 100KB+ programs for a simple code that prints "hello world" to the screen !!!! how can i reduce the size of my programs ?? |
Thats crazy.....Because I made a simple text file encryption program and it was only 5KB
|
You must be doing somthing wrong dude. Can you post exactly what code you are using?
|
no i did'nt do anything wrong !!
this is the source code of the program : #include <iostream.h> int main() { cout << "hello world\n"; return 0; } |
hmmm, i have no idea what's going on then. Probally somthing to do with your compiller.
|
It's most probably the compiler - I'm afraid the only thing you can do is deal with it.
|
With this code using win98:
:
#include <iostream>:
g++ -o big big.cppUsing different switches to first convert to asm then compile :
g++ -s big.cpp -o big2I'm not sure if this can be reduced further other than switching to C. |
Try giving it the switch -Os, that will likely help it a lot. I do not think that one header is causing that much bloat... it is also possible that you are generating debug information and having that inserted in there?
|
On win98 with mingw gcc version 3.2 the -Os switch still gave me 438kb.
Using this code and saving as a C file. :
#include <stdio.h>:
gcc -o bigc bigc.cCompiled with: :
gcc -s bigc.c -o bigc2FWIW VC++6 gave me an executable of 221kb for the cpp code. |
As an interesting note I decided to compile the exact same program and these are my results:
:
gcc -Os hello.c; ls -las a.out;Only 6.8k in size... strange difference there... :
gcc hello.c; ls -las a.out;No change in results here.... :
bash-2.05b$ gcc -s hello.cHalf the space saved here... but that is because the "-s" option strips uneeded and debugging information from the executable... I got the same results when I ran this: :
bash-2.05b$ gcc -Os hello.cNow one thing we need to bear in mind is that I compiled this code to run on linux, which means that if you are using windows than we will have different executable formats, ELF in nature is smaller than windows' PE32 format. Unstripped code will always vary in size depending on the amount of debugging information your compiler puts in there by default, and the format that it uses to record this information.. that may not be unusual sizes at all for what you are attempting to accomplish. Actually they seem very reasonable in my opinion. Here is more information about my OS and compiler: :
bash-2.05b$ uname -a; uptime; gcc -v; |
| All times are GMT -5. The time now is 12:58 AM. |
Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC