![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Programmer
Join Date: Nov 2004
Location: Bierut - Lebanon
Posts: 34
Rep Power: 0
![]() |
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> |
|
|
|
|
|
#2 |
|
Expert Programmer
Join Date: Sep 2004
Location: Ontario, Canada
Posts: 550
Rep Power: 4
![]() |
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 |
|
|
|
|
|
#3 |
|
Programming Guru
![]() ![]() |
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! |
|
|
|
|
|
#4 |
|
Programmer
Join Date: Nov 2004
Location: Bierut - Lebanon
Posts: 34
Rep Power: 0
![]() |
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> |
|
|
|
|
|
#5 |
|
Programming Guru
![]() ![]() |
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! |
|
|
|
|
|
#6 |
|
I eat cake for breakfast.
![]() ![]() ![]() ![]() Join Date: Jul 2004
Location: In my box.
Posts: 4,434
Rep Power: 9
![]() |
It's most probably the compiler - I'm afraid the only thing you can do is deal with it.
|
|
|
|
|
|
#7 |
|
Hobbyist Programmer
Join Date: Nov 2004
Location: 1691 miles East of L.A.
Posts: 159
Rep Power: 4
![]() |
With this code using win98:
#include <iostream>
using namespace std;
int main()
{
cout << "hello world\n";
return 0;
}g++ -o big big.cpp Using different switches to first convert to asm then compile g++ -s big.cpp -o big2 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! |
|
|
|
|
|
#8 |
|
Expert Programmer
|
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 <geek@cliffordroche.com> Web Hosting: http://www.crd-hosting.com Consulting: http://www.crdev-consulting.com |
|
|
|
|
|
#9 |
|
Hobbyist Programmer
Join Date: Nov 2004
Location: 1691 miles East of L.A.
Posts: 159
Rep Power: 4
![]() |
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;
}gcc -o bigc bigc.c Compiled with: gcc -s bigc.c -o bigc2 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! |
|
|
|
|
|
#10 |
|
Expert Programmer
|
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 <geek@cliffordroche.com> Web Hosting: http://www.crd-hosting.com Consulting: http://www.crdev-consulting.com |
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|