August 26th, 2003, 03:27 PM
Compiler is Microsoft Visual C++ .NET, architect edition
I want the smallest filesize possible with C, without packing/compressing. This program that doesn't do anything is 20.5K, If I just have an int main() without any includes, it's around the same size, if not bigger.. why?
Does the size differ greatly with each compiler? What causes the huge filesize for `programs that don't do anything`.
I compile with default settings, "release", not "debug"..
I opened some files in notepad, and found this, what is it?
- unable to initialize heap
- not enough space for lowio initialization
- not enough space for stdio initialization
- pure virtual function call
- not enough space for _onexit/atexit table
- unable to open console device
- unexpected heap error
- unexpected multithread lock error
- not enough space for thread data
This application has requested the Runtime to terminate it in an unusual way.
Please contact the application's support team for more information.
- not enough space for environment
- not enough space for arguments
- floating point not loaded
Microsoft Visual C++ Runtime Library
Program: ... <program name unknown>
int APIENTRY WinMain(HINSTANCE hInst, HINSTANCE hPrevInst, LPSTR CmdLine, int CmdShow)
August 26th, 2003, 03:35 PM
if you use linux you can use the strip utility to make your programs much smaller. it removes the symbol table and all sorts of other stuff that i dont know about. there's always lots of junk inside of your exe's. also i think it depends how you link, statically or dynamically. the former making a much larger exe. all this stuff can be found with 'man gcc' but i'm not sure about in windows sorry.
edit: here's a small example of the crap packed into you exe, this is for a program like so:
pretty big difference.
Last edited by infamous41md; August 26th, 2003 at 03:40 PM.
August 26th, 2003, 03:59 PM
Welcome to the wonderful world of Windows bloatware. I have had 50 line codes wind up with exes of more than a couple of megabytes! You can try asking to minimize the size of your code under optimzations (Project, Settings, C/C++, Category "Optimizations") and see if that makes any difference (didn't for a program I tested it on). I imagine, as infamous41md pointed out, that there are possibly ways to strip some of that out of your exe, but some of that stuff is needed for the runtime linker (for DLLs) and if you try to remove it it is nearly 100% likely your program will crash.
August 26th, 2003, 04:10 PM
Damn, yes, none of the settings in msvc do ANYTHING, not even a byte off.
I compiled with mingW, 14K, not bad.
Last edited by movEAX_444; August 26th, 2003 at 04:19 PM.
August 26th, 2003, 04:27 PM
You're building a win32 application. Try building a console application with this code and see if that helps the file size:
August 26th, 2003, 04:51 PM
Also, some of the obvious things are to check whether you are building a debug or release version of your program and whether you are statically or dynamically linking in the libraries.
Those made a difference in MSVC++6, but I don't know yet whether they would in .NET. I'm just starting my VB.NET class tonight [shudder].
August 26th, 2003, 05:07 PM
Yeah, I am 'releasing', debug is like 108K at least. I don't use anything .NET, I just use msvc because of the IDE, I will probably compile w/ mingW when I'm done tweaking the projects around.