2

So I did some research and found out about rs.exe in Windows to convert my resources.rs file containing a name to_do and PATH to ico to res. The only problem is after navigating to its directory and running the command rs resource.exe. I get the error RC1109 which im told is that the rc.exe can not find the path.

What am I doing wrong? should I keep my resources.rs file in the same folder as the rc.exe?

do I have to format the text included in the file in some sort of way?

As always thanks for your help!

  • 1
    You mention rc.exe, but have tagged rs.exe? Overall, are you asking how you can add an icon to your exe, build from `cargo build`? – vallentin Mar 28 '21 at 08:22

1 Answers1

5

You can use the winres crate to set an icon for the .exe when you run cargo build or cargo run.

Add this to your Cargo.toml:

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

[build-dependencies]
winres = "0.1"

Then create a build.rs file in the same directory where the Cargo.toml is located, with the following content:

extern crate winres;

fn main() {
  if cfg!(target_os = "windows") {
    let mut res = winres::WindowsResource::new();
    res.set_icon("my_icon.ico"); // Replace this with the filename of your .ico file.
    res.compile().unwrap();
  }
}

Then you have to copy your .ico file in that same directory, too. Don't forget to change the filename in build.rs.

frankenapps
  • 5,800
  • 6
  • 28
  • 69