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:
- gcc -g0 hw.cpp -o hw.out (disable debug info) => size is 17k (same if
-g0is removed) - gcc -g3 hw.cpp -o hw.out (maximum debug info) => size is 44k
But the default compile for MSVC (cl version 19.26.28806) outputs a much bigger file:
- cl hw.cpp /link /out:hw.exe => size is 101k
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.