'Reduce MSVC compiler executable size?
I have a simple hello world program, but the .exe is somehow 100kb big.
#include <stdio.h>
int main()
{
printf("Hello world");
return 0;
}
I'm currently using a .bat file to call the commands.
@echo off
call "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Auxiliary\Build\vcvarsall.bat" x86
cl /nologo /O2 /W3 ./Main.c /FeHello.exe
I am using MSVC compiler from Visual Studio 2019 to compile with the command prompt.
Thanks
Solution 1:[1]
Large size is caused by linking runtime statically. /MD switch can be used in order to link it dynamically and shrink size of the executable.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | user7860670 |
