#resources #windows #rc #build-time #compilation

build windres

Compiles Windows resource files (.rc) into a Rust program

4 releases

Uses old Rust 2015

0.2.2 Feb 26, 2021
0.2.1 Jul 18, 2018
0.2.0 Jul 1, 2018
0.1.0 Oct 20, 2017

#228 in Build Utils

Download history 193/week @ 2023-12-08 239/week @ 2023-12-15 180/week @ 2023-12-22 134/week @ 2023-12-29 167/week @ 2024-01-05 204/week @ 2024-01-12 160/week @ 2024-01-19 197/week @ 2024-01-26 140/week @ 2024-02-02 242/week @ 2024-02-09 248/week @ 2024-02-16 424/week @ 2024-02-23 256/week @ 2024-03-01 273/week @ 2024-03-08 237/week @ 2024-03-15 257/week @ 2024-03-22

1,105 downloads per month
Used in 6 crates

Apache-2.0 OR MIT

16KB
275 lines

windres-rs

Travis CI Crates.io Docs.rs

windres is a Rust library crate for compiling Windows resource (.rc) files into object files at build time, which are then forwarded to the linker. This allows for embedding icons, version information, native UI data, etc. in binaries compiled from Rust code.

Example

The following example demonstrates how to embed an icon in a binary crate:

// hello-world.rc

1 ICON "hello-world.ico"
// build.rs

extern crate windres;

use windres::Build;

fn main() {
    Build::new().compile("hello-world.rc").unwrap();
}

Usage

You need to install the resource compiler for your target ABI in order for windres to work. Currently the following compilers are supported:

  • windres.exe for GNU targets (included in the mingw-w64 toolchain)
  • rc.exe for MSVC targets (included in the Windows SDK, which can be installed via Visual Studio Installer)

Once the appropriate resource compiler is installed, add windres as a build dependency in Cargo.toml:

[target.'cfg(windows)'.build-dependencies]
windres = "0.2"

Then, create a build script (if you haven't already) and add a reference to windres:

#[cfg(windows)]
extern crate windres;

License

Licensed under either of

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

Dependencies

~0–345KB