Thread: .exe size

  1. #1

    .exe size

    I've just gotten into C++ and am now able to creat basic consol programs.
    However i've come up with the problem that all the programs i make are always very large when complied into .exe (i got a 32 line program that is 1.2 mb)
    I've got this suspicion that it has somthing to do with the with the header files. (correct me if im wrong please)
    I use Dev C++ and the only header file i include is iostream.h

    How can I bring down these huge file sizes in the .exe?

    thx for your time
    -Face

  2. #2
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,897
    >I've got this suspicion that it has somthing to do with the with the header files.
    That would be my best guess as well. Bloated libraries are a problem (though not as much as they used to be) with the implementation's design. You can't fix it, but you can complain to the vendor. That's always fun.
    My best code is written with the delete key.

  3. #3
    Registered User
    Join Date
    Jan 2003
    Posts
    648
    At least in VC++, try compiling in release mode, use smaller .exe options, optimize your code and the compiler settings, and align the file to smaller boundaries (compiler option).

  4. #4
    Registered User major_small's Avatar
    Join Date
    May 2003
    Posts
    2,787
    Quote Originally Posted by Blurry_Face
    I use Dev C++ and the only header file i include is iostream.h
    what version of Dev-C++? I suggest you get the newest version... I'm asking because the newer versions would give you a nasty compilation error for using iostream.h, because it's old and the new standard calls for iostream...
    Join is in our Unofficial Cprog IRC channel
    Server: irc.phoenixradio.org
    Channel: #Tech


    Team Cprog Folding@Home: Team #43476
    Download it Here
    Detailed Stats Here
    More Detailed Stats
    52 Members so far, are YOU a member?
    Current team score: 1223226 (ranked 374 of 45152)

    The CBoard team is doing better than 99.16% of the other teams
    Top 5 Members: Xterria(518175), pianorain(118517), Bennet(64957), JaWiB(55610), alphaoide(44374)

    Last Updated on: Wed, 30 Aug, 2006 @ 2:30 PM EDT

  5. #5
    Yes i have the lates version of Dev-C++

    After playing with the compiling optamising options I belive that that doesn't help or if it does it doesn't do very much.

  6. #6
    Registered User major_small's Avatar
    Join Date
    May 2003
    Posts
    2,787
    how can you include iostream.h with the newest version of Dev-C++?

    unless you defeated the warning, which would be almost entirely useless...
    Join is in our Unofficial Cprog IRC channel
    Server: irc.phoenixradio.org
    Channel: #Tech


    Team Cprog Folding@Home: Team #43476
    Download it Here
    Detailed Stats Here
    More Detailed Stats
    52 Members so far, are YOU a member?
    Current team score: 1223226 (ranked 374 of 45152)

    The CBoard team is doing better than 99.16% of the other teams
    Top 5 Members: Xterria(518175), pianorain(118517), Bennet(64957), JaWiB(55610), alphaoide(44374)

    Last Updated on: Wed, 30 Aug, 2006 @ 2:30 PM EDT

  7. #7
    Registered User Dante Shamest's Avatar
    Join Date
    Apr 2003
    Posts
    970
    Add -s in the Linker options in Dev-C++.

    You can find it in Project -> Project Options -> Parameters

  8. #8
    Registered User
    Join Date
    Aug 2003
    Posts
    470
    Make sure your not outputting debugging information or using static linking.

  9. #9
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,660
    A recent thread on this very subject is here
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  10. #10
    Via removing the debug info i managed to shrink my 32 line program from 1.2 mb to 400kb.
    Still absurde but bearably absurde.
    Thanks alot for your help and input guys.

  11. #11
    Registered User
    Join Date
    Feb 2002
    Posts
    20
    Try using the command "strip yourexe.exe". It will take out all the debugging information and probably bring the exe down half it's original size.

    Another thing you can do is try to remove any header files that you do not need.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Heapsort
    By xENGINEERx in forum C Programming
    Replies: 2
    Last Post: 03-30-2008, 07:17 PM
  2. Pointer Size Relative To Integers?
    By SMurf in forum C Programming
    Replies: 1
    Last Post: 04-18-2006, 06:58 AM
  3. Invalid conversion from 'void*' to 'BYTE' help
    By bikr692002 in forum C++ Programming
    Replies: 9
    Last Post: 02-22-2006, 11:27 AM
  4. An exercise in optimization
    By Prelude in forum Contests Board
    Replies: 10
    Last Post: 04-29-2005, 03:06 PM