I am curious why a compiled console version of "hello world" is 72 kb while the Windows GUI equivalent is only 4 kb. Does it have to do with my include statements? Here is my code for each program, first the console and then the Windows version:
include <iostream.h>
include <stdio.h>
include <stdlib.h>
int main()
{
cout << "Hello World!" << endl;
cout << "Press ENTER to continue..." << endl;
getchar ();
return 0;
}
<iostream> is a large statically linked library. The Windows API on the other hand is provided to your app as a DLL so does not form part of the executable.
Since in MinGW the C library is also a DLL, if you want small executables, use the C library only.
It is largely a fixed overhead, so for any significantly sized application it will make not be significant. Don't sweat the small stuff.
Clifford
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I am curious why a compiled console version of "hello world" is 72 kb while the Windows GUI equivalent is only 4 kb. Does it have to do with my include statements? Here is my code for each program, first the console and then the Windows version:
include <iostream.h>
include <stdio.h>
include <stdlib.h>
int main()
{
cout << "Hello World!" << endl;
cout << "Press ENTER to continue..." << endl;
getchar ();
return 0;
}
include <windows.h>
int WINAPI WinMain (HINSTANCE hInstance,
HINSTANCE hPrevInstance,
PSTR szCmdLine,
int iCmdShow)
{
MessageBox (NULL, "Hello", "Hello Demo", MB_OK);
return (0);
}
<iostream> is a large statically linked library. The Windows API on the other hand is provided to your app as a DLL so does not form part of the executable.
Since in MinGW the C library is also a DLL, if you want small executables, use the C library only.
It is largely a fixed overhead, so for any significantly sized application it will make not be significant. Don't sweat the small stuff.
Clifford