I have the following simple C++ program in a file called "hw.cpp":
#include <stdio.h>
int main(int argc, char* args[])
{
printf("Hello, world!\n");
return 0;
}
Compiling with gcc 9.3.0 (Ubuntu), gives the following results:
-g0 is removed)But the default compile for MSVC (cl version 19.26.28806) outputs a much bigger file:
Why is the MSVC version so big? Is this related to debug information and how do is debug information disabled? The cl.exe compiler options don't have an obvious equivalent for the gcc -gN options.
These are the hw.exe sizes I am seeing for the combinations of static/dynamic linking of the C runtime vs. debug/release builds for a default 32b compile of your hw.cpp with VC++ 2019.
debug release
static (cl /MTd) 279,040 (cl /MT) 101,888
dynamic (cl /MDd) 10,240 (cl /MD) 8,192
The 32b release build cl /MD hw.cpp dynamically linked to VCRUNTIME140.DLL runtime has 8k. The big jump in size with /MT comes from statically linking the core C support, stream library etc.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With