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?
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.
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.
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.
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.
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.
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.