Visual C++ 2015 and UPX

closed account (E0p9LyTq)
I have routinely used GCC/TDM-GCC in the past and was rather disappointed in the compilers bloating up a program when using C++. Even a "simple" Hello World program ended up being nearly 600K for a release version. I would use UPX to compress executables.

I decided to install VS2015 community and was pleasantly surprised to know the file size was vastly reduced. Same source and exe files were 10K/12K in size.

I used UPX on a VS created program, not that much size savings. So I decompressed the file and tried running it. The program promptly crashed. Oh oops.

I tried another newly created exe, compressing and decompressing, and it too crashed.

Hmmm, it looks like UPX really mangles things, even decompressing, if VS created the program.

Nothing really earth-shattering, just some weird thing I noticed. I don't really need to compress a program created with VS, it is already smaller than one created with GCC.
Last edited on
It's worth noting that if you want to distribute that executable, your users will have to install a ~1.5 MiB redistributable package (unless you bundle it). I can't remember ATM whether statically linked executables are distributable.
closed account (E0p9LyTq)
I hadn't considered the file size reduction was because of redistributable package DLLs. D'OH!

I see that the redistributable packages for VS2015 are 13.1MB (x86) and 13.9MB(x64).

I can't seem to find static linking in VC++2015 Community. I'd bet that is a "must pay for" feature.
Last edited on
I do see it in 2013 CE, so it'd be weird. Check under code generation, runtime library.
closed account (E0p9LyTq)
I found it! Project Properties -> Configuration Properties -> C/C++ -> Code Generation -> Runtime Library.

Use Multi-Threaded instead of Multi-Threaded DLL and the exe size is 160KB. But no redist required!

160KB is a better file size than 577+KB as generated by GCC.

Compress and decompress with UPX and still it crashes the runtime. Yeah, a VS generated app does not like getting meddled with.
closed account (E0p9LyTq)
Coincidentally UPX compress a GCC generated app and the file size ends up being approximately the same size as the same app (uncompressed) created in VS.
Last edited on
I would suspect that VS actually compresses the file when created.
I really hate that Runtime Library option. I'd rather download larger files than install dozens of different versions of the redistributable. I always make sure that my executables don't need the redist.
closed account (E0p9LyTq)
I really hate that Runtime Library option.

.NET/VS runtimes really are a pain and bloated. Not only do I have multiple versions of VS runtimes installed on my PC (2005, 2008, 2010, 2013 and now 2015) that various programs wanted to install to work, each version's runtime installed two different runtimes because this PC is 64-bit. An x86 version and x64.

There are multiple runtime versions even within one VS version. Even more bloat.
Yes, it seems that at some point VS started to pack its output by default. I just noticed while working with 2010 that Process Explorer colors my images purple (packed image).
Topic archived. No new replies allowed.