mxre / winres

Create and set windows icons and metadata for executables with a rust build script
MIT License
297 stars 42 forks source link

Adding winres increases binary size #26

Closed robinthunstrom closed 3 years ago

robinthunstrom commented 4 years ago

Hi!

I added this crate as dependency to add an icon to my project and expected this to have zero effect on the final binary size. To my surprise was the binary size increased. Is this expected or not?

This is how my toml looks like...

[package]
#...
build = "build.rs"

#...
[target.'cfg(windows)'.build-dependencies]
winres = "0.1.11"
wngr commented 3 years ago

winres.a is statically linked, so there is obviously some overhead.

mxre commented 3 years ago

winres does not link code into binary. The static library is a necessity to link the icon (and other resources) into the executable. The static library (which should be called resource.lib but is a .ar archive) in actuality is the output of the rc.exe resource compiler usually with the suffix .res, but since we need the rust compiler to link it a library suffix is needed.

Back to the OP's comment the t the binary size increases. This must obviously be the case as now the binary contains in itself the icon and other resources like the version string information. If you use a particularly large icon (like 512px) then the binary size may increase by more than 1MB. (pictures need size). I'm not sure what OP originally expected but if you add content to a file its size will always increase.

So I'm closing this as invalid.