Large EXEs

Discussion in 'Web Design & Programming' started by Addis, Jan 19, 2005.

  1. Addis

    Addis The King

    Likes Received:
    91
    Trophy Points:
    48
    Ok for those of you who are C++ programmers help please!

    I'm using Dev-C++ to compile some small C++ programs (no more than 50 lines or so) and when I compile the project i get huge exes like 400kb.

    Even small programs such as
    Code:
    #include <iostream>
    using namespace std;
    int main(void)
    {
    cout << "Filetest" << endl;
    return 0;
    }
    

    Now googling it I've found that not including the debug info cuts it down to 220 or so and then enabling strip executable and best optimisation cuts it by 5kb or so again. Still too big.

    I found that this is to do with the MingW or Gcc compiler statically linking to <iostream>
    Thing is I've read that you shouldn't really use iostream for small programs and only use libs such as stdio etc. I've tried including them instead but the cout and cin functions don't work. I'm pretty much a n00b to c++ so I'm not sure.

    I've read most of the FAQs to this subject and non seem to really break the exe to 5kb size range.

    Any help please?
     
  2. Addis

    Addis The King

    Likes Received:
    91
    Trophy Points:
    48
    By the way my smilies don't work.
     
  3. syngod

    syngod Moderator

    Likes Received:
    15
    Trophy Points:
    18
    Try out the trial version of ASPack, it should compress it a bit better and also adds a layer of protection to your file.

    The other thing I can think of is try running it through Visual C++ Express, not sure if there is a difference between it and Visual Studio but I've had good luck with VS's compiler.
     
  4. Addis

    Addis The King

    Likes Received:
    91
    Trophy Points:
    48
    I wasn't really wanting to use packers but I'l give them a go.
    I've got a small C program which compiles at only 5kb. But I'm really wanting to stick with C++.
    Also I tried to install VC++ Express but the web installer didn't work.
     
  5. harrack52

    harrack52 Supreme Geek

    Likes Received:
    5
    Trophy Points:
    0
    You could use printf and scanf instead of cout and cin, but then again that would be C, not C++.

    BUT, if you're not doing any OOP, and especially for programs as small as this one, C is just as good.

    I don't really know C++ but I do know Java, so if you got any other questions, I might be able to help.
     
  6. harrack52

    harrack52 Supreme Geek

    Likes Received:
    5
    Trophy Points:
    0
    Ok I tried it with Visual Studio 6.0 , and the exe is 220kb.

    But this
    gives me 172kb.

    EDIT:
    Oh and by the way, you don't need the "return" because the main is a void "function" (I know it's not really a function but anyway...), therefore it doesn't return anything. The compiler allows it but you shouldn't do that.
    For instance, Java would give you an error for that.
     
  7. Addis

    Addis The King

    Likes Received:
    91
    Trophy Points:
    48
    Damn I forgot i was using void for main. Silly..
    So adding the .h makes a difference? When I do it it compiles but still sticks out 212kb. damn cheap (free) IDE.
     
  8. harrack52

    harrack52 Supreme Geek

    Likes Received:
    5
    Trophy Points:
    0
    iostream.h is a file called a library in which certain instructions are defined.

    I've actually always used it like that: #include <file.h>;
    so I wouldn't be able to tell you what the difference is exactly

    And about your exe size, I guess there's not much you can do about it.
     
  9. Addis

    Addis The King

    Likes Received:
    91
    Trophy Points:
    48
    I'll try using VC++ so I'll try downloading it again.
    thanks anyway.
     

Share This Page