33 stable releases

Uses old Rust 2015

1.8.0 Dec 10, 2022
1.7.4 Nov 4, 2022
1.7.3 Jul 3, 2022
1.7.2 Mar 31, 2022
0.1.2 Jan 31, 2017

#11 in Development tools

Download history 7596/week @ 2022-10-10 7401/week @ 2022-10-17 11734/week @ 2022-10-24 10027/week @ 2022-10-31 10435/week @ 2022-11-07 10310/week @ 2022-11-14 10801/week @ 2022-11-21 10547/week @ 2022-11-28 9595/week @ 2022-12-05 9823/week @ 2022-12-12 8468/week @ 2022-12-19 8677/week @ 2022-12-26 8645/week @ 2023-01-02 10531/week @ 2023-01-09 8188/week @ 2023-01-16 8283/week @ 2023-01-23

37,297 downloads per month
Used in 30 crates (25 directly)

MIT license

424 lines

rust-embed-resource TravisCI build status AppVeyorCI build status Licence Crates.io version

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



In your build script, assuming the resource file is called checksums.rc:

extern crate embed_resource;

fn main() {
    // Compile and link checksums.rc

    // Or, to select a resource file for each binary separately
    embed_resource::compile_for("assets/poke-a-mango.rc", &["poke-a-mango", "poke-a-mango-installer"]);
    embed_resource::compile_for("assets/uninstaller.rc", &["unins001"]);

Example: Embedding a Windows Manifest

Courtesy of @jpoles1.

The following steps are used to embed a manifest in your compiled rust .exe file. In this example the manifest will cause admin permissions to be requested for the final executable:

  1. Add the following to your cargo.toml:
embed-resource = "1.8"
  1. In your project root directory, add a file named build.rs with the following:
extern crate embed_resource;
fn main() {
  1. In your project root directory, add a file named app-name-manifest.rc with the following:
#define RT_MANIFEST 24
1 RT_MANIFEST "app-name.exe.manifest"
  1. In your project root directory, add a file named app-name.exe.manifest with the following:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
    <trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
                <requestedExecutionLevel level="requireAdministrator" uiAccess="false"/>
  1. Build your project!


If no cargo:rerun-if-changed annotations are generated, Cargo scans the entire build root by default. Because the first step in building a manifest is an unspecified C preprocessor step with-out the ability to generate the equivalent of cc -MD, we do not output said annotation.

If scanning is prohibitively expensive, or you have something else that generates the annotations, you may want to spec the full non-system dependency list for your manifest manually, so:


for the above example (cf. #41).


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

@SonnyX -- Windows cross-compilation support and testing

@MSxDOS -- finding and supplying RC.EXE its esoteric header include paths

@roblabla -- cross-compilation to Windows MSVC via LLVM-RC

Special thanks

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

  • ThePhD
  • Embark Studios
  • Lars Strojny


~11K SLoC