Closed Joe23232 closed 3 years ago
Crosscompiling is still unsupported and I am working on it.
As for your error, "package.metadata does not exist" its nor an error but an informative message because your Cargo.toml has no [package.metadata.winres] section.
The NotFound error is probably because GNU tools like windres need the ar tool too, try specifying the appropriate tool with set_ar_path("")
(after new
, before compile
)
As for your error, "package.metadata does not exist" its nor an error but an informative message because your Cargo.toml has no [package.metadata.winres] section. The NotFound error is probably because GNU tools like windres need the ar tool too, try specifying the appropriate tool with set_ar_path("") (after new, before compile)
If I fixed this the icon will still not appear as you said Crosscompiling is still unsupported and I am working on it., am I correct?
I uploaded a new version (0.1.12) to crates.io, Please look at #24 and the example in the repository.
Thanks mate
On Wed, Sep 29, 2021 at 6:00 AM Max Resch @.***> wrote:
I uploaded a new version (0.1.12) to crates.io, Please look at #24 https://github.com/mxre/winres/pull/24 and the example in the repository.
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/mxre/winres/issues/33#issuecomment-929579869, or unsubscribe https://github.com/notifications/unsubscribe-auth/AIKO7IP5OTAYCEFI2RLDURDUEINE7ANCNFSM5BPY6G7A . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.
I uploaded a new version (0.1.12) to crates.io, Please look at #24 and the example in the repository.
Both together works for me.
I'm not fully clear on this. Is cross-compilation supported or not? I'm attempting to cross compile for Windows on Linux, and the icon still isn't being set after following the above suggestions. Below is the build script I'm using:
use std::{env, io};
use winres::WindowsResource;
fn main() -> io::Result<()> {
let target_family = env::var("CARGO_CFG_TARGET_FAMILY").unwrap();
if target_family == "windows" {
WindowsResource::new()
.set_toolkit_path("/usr/bin")
.set_windres_path("x86_64-w64-mingw32-windres")
.set_ar_path("x86_64-w64-mingw32-ar")
.set("ProductVersion", "1.1.0")
.set_icon("icon.ico")
.compile()?;
}
Ok(())
}
I'm also using winres 0.1.12
@AshfordN I can't recreate your missing icon with the build.rs you provided. Please look at the output in target/x86_64-pc-windows-gnu/{release,debug}/build/<cratename>/output
should look something like this:
cargo:rustc-link-search=native=/git/winres/example/target/x86_64-pc-windows-gnu/release/build/winres-example-7f6f80bd1c122442/output
cargo:rustc-link-lib=static=resource
the resource file (.rc) itself is in target/x86_64-pc-windows-gnu/{release,debug}/build/<createname>/out
together with its compiled (.o) form and its library form (.a) (because cargo only allows adding static libraries via build script but not single object files)
Also the icon file path is relative to the create and not the build script.
@mxre I did some further testing with a basic project and, using the same build script above, I was able to successfully set the icon. However, I found that if I added a library crate to the package, things stopped working. Since I'm still new to rust, I'm not quite sure if this is an obvious side effect, but I would appreciated any feedback on the matter. Below is a summary of the sample project I'm using:
.
├─src
│ ├─lib.rs
│ └─main.rs
├─build.rs
├─cargo.toml
└─icon.ico
pub mod foo {
pub fn bar() {
println!("this is a test");
}
}
use sample::foo;
fn main() {
foo::bar();
}
same as above
[package]
name = "sample-project"
version = "0.1.0"
edition = "2018"
build = "build.rs"
[lib]
name = "sample"
path = "src/lib.rs"
[build-dependencies]
winres = "0.1"
I'm not able to attached the exact .ico
file, but I guess any should work in this case
Nevermind, I see now that my issue is a dupplicate of #32
Not exactly a duplicate. But certainly unrelated to crosscompiling.
Hi,, I am trying to build an application from (Arch) Linux to Windows.
I use this command
cargo build --release --target x86_64-pc-windows-gnu
and it works just fine. I can execute my program just fine.Now I want to include an icon to my executable.
I followed this post (as shown in the screenshot)
https://stackoverflow.com/questions/30291757/attaching-an-icon-resource-to-a-rust-application
And this works fine if I am compiling on Windows. However on Linux when building for Windows, it fails to add an icon. I have made the following modification:
build.rs
Cargo.toml
However, with the following modification I get this error message:
Does anyone know why this is happening?