[][src]Crate embed_resource

A Cargo build script library to handle compilation and inclusion of Windows resources in the most resilient fashion imaginable


Including Windows resources seems very easy at first, despite the build scripts' abhorrent documentation: compile with windres, then make linkable with ar.

I was very happy with that solution until it was brought to my attention, that MSVC uses something different, and now either windres-ar combo or RC.EXE would be used, which was OK.

Later it transpired, that MSVC is even more incompatible with everything else by way of not having RC.EXE in $PATH (because it would only be reasonable to do so), so another MSVC artisan made the script find the most likely places for RC.EXE to be, and the script grew yet again, now standing at 100 lines and 3.2 kB.

After copying the build script in its entirety and realising how error-prone that was, then being nudged by Shepmaster to extract it to a crate, here we are.


For the purposes of the demonstration we will assume that the resource file's name is "checksums.rc".

In Cargo.toml:

# The general section with crate name, license, etc.
build = "build.rs"

embed-resource = "1.2"

In build.rs:

extern crate embed_resource;

fn main() {


In chronological order:

@liigo -- persistency in pestering me and investigating problems where I have failed

@mzji -- MSVC lab rat

@TheCatPlusPlus -- knowledge and providing first iteration of manifest-embedding code

@azyobuzin -- providing code for finding places where RC.EXE could hide

@retep998 -- fixing MSVC support

Special thanks

To all who support further development on Patreon, in particular:

  • ThePhD



Compile the Windows resource file and update the cargo search path if we're on Windows.