Q:

Different exe sizes when compiling using the Visual C++ Express 2010 IDE and compiling under console with cl command

This is my first question here, i'm a big fan and found many solutions in stackoverflow, so many thanks to all. I would be happy if my question is one that is worth time.
I'm using Windows 7 and Microsft Visual C++ 2010 Express.
The C code is:
int main()
{
    return 0;
}

When compiling the code with the ide, with project properties -> C/C++ -> CodeGeneration -> Runtime Library = /MTd option the exe size is 395,264 bytes.
When compiling the program under console with cl.exe using the Visual Studio Command Prompt
"cl test.c" the exe size is 31,744.
SIZES:
1. 395,264
2.  31,744
Any idea why there is so big differences in the sizes?
Thank You.

A:

Because:

There are many more VC++ compiler options, not just the /M family of options.
Several of those options can affect the executable's size.
The IDE's defaults for a new project are different than the defaults of the compiler and linker themselves.

Somewhere in the IDE, go to your test project's properties. Open Configuration Properties -> C/C++ -> Command Line and Configuration Properties -> Linker -> Command Line. This will show you all options with which your IDE invokes the compiler and linker.
The mere fact that the IDE uses so many options should tell you that it's not using the tools' defaults.
If you go to the command line and invoke the compiler and linker with the same options shown in the IDE, then the resulting executable should be 100% identical.

