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

renaming of the library C was specified, however this crate contains no #[link(...)] attributes referencing this library #2182

Closed
flevi29 opened this issue Mar 27, 2022 · 3 comments

Comments

@flevi29
Copy link

flevi29 commented Mar 27, 2022

Input C/C++ Header

I have no idea what causes the issue, and so I can't narrow it down, and also I'm not even sure if it's related to the header file
https://github.com/NordicID/nur_sdk/blob/master/native/include/NurAPI.h

Bindgen Invocation

    bindgen::Builder::default()
        // blacklist a bunch of types and functions that hopefully will not be utilized
        // https://github.com/rust-lang/rust-bindgen/issues/1556#issuecomment-658317813
        .blocklist_type("LPMONITORINFOEXA?W?")
        // ...
        .blocklist_function("__C_specific_handler")
        // The input header we would like to generate
        // bindings for.
        .header("wrapper.h")
        // Tell cargo to invalidate the built crate whenever any of the
        // included header files changed.
        .parse_callbacks(Box::new(bindgen::CargoCallbacks))
        // Finish the builder and generate the bindings.
        .generate()
        // Unwrap the Result and panic on failure.
        .expect("Unable to generate bindings");

Actual Results

error: renaming of the library `C` was specified, however this crate contains no `#[link(...)]` attributes referencing this library

Expected Results

I expect it to successfully build.

I suspect my problem is probably related to

    let root_dir = env::var("CARGO_MANIFEST_DIR").unwrap();
    println!("cargo:rustc-link-lib={}", Path::new(&root_dir)
        .join("NUR-lib")
        .display());

    // Tell cargo to invalidate the built crate whenever the wrapper changes
    println!("cargo:rerun-if-changed=wrapper.h");

NUR-lib contains x86 and x64 from https://github.com/NordicID/nur_sdk/tree/master/native/windows

I cannot determine what causes the error though or where to even start looking for a fix, I don't understand the implications of this error message, nor have I found another issue related to it other than this.

@emilio
Copy link
Contributor

emilio commented Mar 27, 2022

Yeah this seems unlikely to be related to bindgen, bindgen intentionally doesn't mess with anything compiler-related, just generates code. That said, maybe the CargoCallbacks are causing trouble? That'd be a bit surprising but... Does removing that help?

If not, can you post some concrete steps to reproduce? Something like:

  1. clone this repo
  2. cargo build
  3. ...

Or so?

@flevi29
Copy link
Author

flevi29 commented Mar 27, 2022

I commented the line

// .parse_callbacks(Box::new(bindgen::CargoCallbacks))

same error.

... can you post some concrete steps to reproduce?

Sure!

  1. clone this repo
  2. cargo build
  3. should err

@pvdrz
Copy link
Contributor

pvdrz commented Nov 23, 2022

I cloned the repo and tried building it. The linking error is no longer present. There's an error related to duplicated constants but it seems unrelated to this. Feel free to reopen.

@pvdrz pvdrz closed this as completed Nov 23, 2022
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

3 participants