Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Nov 12th, 2004, 5:09 AM   #1
Dia_Byte
Programmer
 
Join Date: Nov 2004
Location: Bierut - Lebanon
Posts: 34
Rep Power: 0 Dia_Byte is on a distinguished road
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 ??
__________________
<removed by Administrator>
Dia_Byte is offline   Reply With Quote
Old Nov 12th, 2004, 7:52 AM   #2
Benoit
Expert Programmer
 
Benoit's Avatar
 
Join Date: Sep 2004
Location: Ontario, Canada
Posts: 550
Rep Power: 4 Benoit is on a distinguished road
Thats crazy.....Because I made a simple text file encryption program and it was only 5KB
__________________
Johnny was a chemist's son but Johnny is no more, for what Johnny thought was H2O was H2SO4
Benoit is offline   Reply With Quote
Old Nov 12th, 2004, 8:40 AM   #3
Pizentios
Programming Guru
 
Pizentios's Avatar
 
Join Date: May 2004
Location: Brandon, Manitoba, Canada
Posts: 2,023
Rep Power: 7 Pizentios is on a distinguished road
Send a message via ICQ to Pizentios Send a message via MSN to Pizentios
You must be doing somthing wrong dude. Can you post exactly what code you are using?
__________________
Profanity is the one language that all programmers understand.

Check out my Blog <---updated Nov 30 2007!
Pizentios is offline   Reply With Quote
Old Nov 12th, 2004, 10:55 AM   #4
Dia_Byte
Programmer
 
Join Date: Nov 2004
Location: Bierut - Lebanon
Posts: 34
Rep Power: 0 Dia_Byte is on a distinguished road
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;
}
__________________
<removed by Administrator>
Dia_Byte is offline   Reply With Quote
Old Nov 12th, 2004, 11:01 AM   #5
Pizentios
Programming Guru
 
Pizentios's Avatar
 
Join Date: May 2004
Location: Brandon, Manitoba, Canada
Posts: 2,023
Rep Power: 7 Pizentios is on a distinguished road
Send a message via ICQ to Pizentios Send a message via MSN to Pizentios
hmmm, i have no idea what's going on then. Probally somthing to do with your compiller.
__________________
Profanity is the one language that all programmers understand.

Check out my Blog <---updated Nov 30 2007!
Pizentios is offline   Reply With Quote
Old Nov 12th, 2004, 12:19 PM   #6
Ooble
I eat cake for breakfast.
 
Ooble's Avatar
 
Join Date: Jul 2004
Location: In my box.
Posts: 4,434
Rep Power: 9 Ooble is on a distinguished road
It's most probably the compiler - I'm afraid the only thing you can do is deal with it.
__________________
Me :: You :: Them
Ooble is offline   Reply With Quote
Old Nov 12th, 2004, 12:33 PM   #7
lostcauz
Hobbyist Programmer
 
Join Date: Nov 2004
Location: 1691 miles East of L.A.
Posts: 159
Rep Power: 4 lostcauz is on a distinguished road
With this code using win98:
#include <iostream>
using namespace std;

int main()
{
  cout << "hello world\n";
  return 0;
}
Compiled with MingW using
g++ -o big big.cpp
gave me an executable of 438kb
Using different switches to first convert to asm then compile
g++ -s big.cpp -o big2
gave me 206kb
I'm not sure if this can be reduced further other than switching to C.
__________________
-- lostcauz

Stepped in what?...
Behind whose barn?...
I didn't even know they had a cow!
lostcauz is offline   Reply With Quote
Old Nov 12th, 2004, 4:45 PM   #8
kurifu
Expert Programmer
 
kurifu's Avatar
 
Join Date: Jul 2004
Location: Halifax, Nova Scotia (Canada)
Posts: 784
Rep Power: 5 kurifu is on a distinguished road
Send a message via ICQ to kurifu Send a message via MSN to kurifu
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?
__________________
Clifford Matthew Roche &lt;geek@cliffordroche.com&gt;
Web Hosting: http://www.crd-hosting.com
Consulting: http://www.crdev-consulting.com
kurifu is offline   Reply With Quote
Old Nov 12th, 2004, 5:16 PM   #9
lostcauz
Hobbyist Programmer
 
Join Date: Nov 2004
Location: 1691 miles East of L.A.
Posts: 159
Rep Power: 4 lostcauz is on a distinguished road
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>

int main()
{
  printf("hello world\n");
  return 0;
}
Compiled with:
gcc -o bigc bigc.c
gives 22kb

Compiled with:
gcc -s bigc.c -o bigc2
nets 11kb.

FWIW VC++6 gave me an executable of 221kb for the cpp code.
__________________
-- lostcauz

Stepped in what?...
Behind whose barn?...
I didn't even know they had a cow!
lostcauz is offline   Reply With Quote
Old Nov 12th, 2004, 10:20 PM   #10
kurifu
Expert Programmer
 
kurifu's Avatar
 
Join Date: Jul 2004
Location: Halifax, Nova Scotia (Canada)
Posts: 784
Rep Power: 5 kurifu is on a distinguished road
Send a message via ICQ to kurifu Send a message via MSN to kurifu
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;
8 -rwxr-xr-x 1 kurifu users 6828 Nov 13 00:13 a.out

Only 6.8k in size... strange difference there...

gcc hello.c; ls -las a.out;
8 -rwxr-xr-x 1 kurifu users 6828 Nov 13 00:15 a.out

No change in results here....

bash-2.05b$ gcc -s hello.c
bash-2.05b$ ls -las a.out
4 -rwxr-xr-x 1 kurifu users 3180 Nov 13 00:16 a.out

Half 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.c
bash-2.05b$ ls -las a.out
8 -rwxr-xr-x 1 kurifu users 6828 Nov 13 00:20 a.out
bash-2.05b$ strip a.out
bash-2.05b$ ls -las a.out
4 -rwxr-xr-x 1 kurifu users 3160 Nov 13 00:20 a.out

Now 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;
Linux tsukasa 2.6.9-gentoo-r1 #1 Fri Nov 5 21:16:53 AST 2004 i686 Mobile Intel(R) Pentium(R) 4 - M CPU 2.40GHz GenuineIntel GNU/Linux
 00:23:42 up 1 day, 10:49, 3 users, load average: 0.06, 0.27, 0.25
Reading specs from /usr/lib/gcc-lib/i686-pc-linux-gnu/3.3.4/specs
Configured with: /var/tmp/portage/gcc-3.3.4-r1/work/gcc-3.3.4/configure --prefix=/usr --bindir=/usr/i686-pc-linux-gnu/gcc-bin/3.3 --includedir=/usr/lib/gcc-lib/i686-pc-linux-gnu/3.3.4/include --datadir=/usr/share/gcc-data/i686-pc-linux-gnu/3.3 --mandir=/usr/share/gcc-data/i686-pc-linux-gnu/3.3/man --infodir=/usr/share/gcc-data/i686-pc-linux-gnu/3.3/info --enable-shared --host=i686-pc-linux-gnu --target=i686-pc-linux-gnu --with-system-zlib --enable-languages=c,c++,f77,objc --enable-threads=posix --enable-long-long --disable-checking --disable-libunwind-exceptions --enable-cstdio=stdio --enable-version-specific-runtime-libs --with-gxx-include-dir=/usr/lib/gcc-lib/i686-pc-linux-gnu/3.3.4/include/g++-v3 --with-local-prefix=/usr/local --enable-shared --enable-nls --without-included-gettext --disable-multilib --enable-__cxa_atexit --enable-clocale=generic
Thread model: posix
gcc version 3.3.4 20040623 (Gentoo Linux 3.3.4-r1, ssp-3.3.2-2, pie-8.7.6)
__________________
Clifford Matthew Roche &lt;geek@cliffordroche.com&gt;
Web Hosting: http://www.crd-hosting.com
Consulting: http://www.crdev-consulting.com
kurifu is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 2:40 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC