Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incompatible linking modifiers +bundle and +whole-archive #7

Closed
ChristophB opened this issue Jan 26, 2023 · 3 comments
Closed

Incompatible linking modifiers +bundle and +whole-archive #7

ChristophB opened this issue Jan 26, 2023 · 3 comments

Comments

@ChristophB
Copy link

rustc version: rustc 1.66.1 (90743e729 2023-01-10)
winresource version: 0.1.14

I get the following error when I cross compile from Debian 11:
"error: the linking modifiers +bundle and +whole-archive are not compatible with each other when generating rlibs"

Changing

println!("cargo:rustc-link-lib=static:+whole-archive=resource");
to:

println!("cargo:rustc-link-lib=static:-bundle,+whole-archive=resource");

resolves this issue. But i don't know if this breaks builds with previous rustc versions...


Example build.rs:

// build.rs

fn main() {
    if std::env::var("CARGO_CFG_TARGET_OS").unwrap() == "windows"
        && std::env::var("PROFILE").unwrap() == "release"
    {
        let mut res = winresource::WindowsResource::new();

        res.set_icon("assets/favicon.ico")
            .set("ProductName", "some name")
            .set("CompanyName", "some company")
            .set("ProductVersion", "0.1.0")
            .set("FileVersion", "0.1.0.0")
            .set("FileDescription", "some description")
            .set("LegalCopyright", "Copyright © Example")
            .compile()
            .unwrap();
    }
}
@ChristophB ChristophB changed the title Incompatible linking modifiers +bundle and +whole-archive Incompatible linking modifiers +bundle and +whole-archive Jan 27, 2023
@BenjaminRi
Copy link
Owner

BenjaminRi commented Jan 27, 2023

Interesting. I cannot reproduce it on Ubuntu 22.04 LTS.

beni@mainpc:~/rust/example/target/x86_64-pc-windows-gnu/debug$ rustc --version
rustc 1.66.1 (90743e729 2023-01-10)
beni@mainpc:~/rust/example/target/x86_64-pc-windows-gnu/debug$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 22.04.1 LTS
Release:        22.04
Codename:       jammy

I'll have to quickly setup docker / a VM to see what's up with this.

@ChristophB
Copy link
Author

It seems that my project setup was a bit messed up (I'm still a rust newby). I had a src/lib.rs next to my src/main.rs. After removing the src/lib.rs, cross compilation worked!

Sorry to have bothered you with this issue.

@BenjaminRi
Copy link
Owner

After removing the src/lib.rs, cross compilation worked!

Oh, that could explain things. A resource can only be applied to a binary, not a library.

Sorry to have bothered you with this issue.

No problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants