How do you set the binary file icon? #2026
-
Hey guys, I managed to set the app icon (window decorator and taskbar) but I don't know how to set the binary file icon. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
This is not really an Though for Rust 1.61 and above, the crate doesn't work, so you'll have to use a fork containing the fix instead. [build-dependencies]
winres = { git = "https://github.com/Nilstrieb/winres", branch = "linking-flags" } After that, you'll also need to add winres metadata section to your Then, at last you'll need to add a build script (a file use std::io;
use winres::WindowsResource;
// for eg. this is my build script
// I've tested this on linux and windows with rust 1.64
fn main() -> io::Result<()> {
if std::env::var("CARGO_CFG_TARGET_FAMILY").unwrap() == "windows" {
let mut res = WindowsResource::new();
match std::env::var("CARGO_CFG_TARGET_ENV").unwrap().as_str() {
"gnu" => {
res.set_ar_path("x86_64-w64-mingw32-ar")
.set_windres_path("x86_64-w64-mingw32-windres");
}
"msvc" => {}
_ => panic!("unsupported env"),
};
res.set_icon("assets/icon.ico");
res.compile()?;
}
Ok(())
} This here is the example build script on Take a look at these for more Edit: Fix typos |
Beta Was this translation helpful? Give feedback.
This is not really an
egui
question but Icon resources for windows binaries can easily be set using the winres crate.Though for Rust 1.61 and above, the crate doesn't work, so you'll have to use a fork containing the fix instead.
So just add the forked
winres
as a build dependency in yourCargo.toml
:After that, you'll also need to add winres metadata section to your
Cargo.toml
, see winres for details.The section can be left completely empty if you want though, I had to add it since
winres
fails for me if I don't have its section in theCargo.toml
.Then, at last you'll need to add a b…