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

Linking fails for windows targets #391

Open
pscschn opened this issue Jan 16, 2025 · 1 comment
Open

Linking fails for windows targets #391

pscschn opened this issue Jan 16, 2025 · 1 comment

Comments

@pscschn
Copy link

pscschn commented Jan 16, 2025

Description
I am encountering a linker error during the build process for windows targets using a custom function list for native-pkcs11.

How to reproduce

I've uploaded my code to a temp repo:

pscschn/issue-native-pkcs11-rs

Build for a windows target:

cargo build --target x86_64-pc-windows-gnu

Behavior

The build fails with message:

= note: /usr/lib/gcc/x86_64-w64-mingw32/14.1.1/../../../../x86_64-w64-mingw32/bin/ld: ...target/x86_64-pc-windows-gnu/debug/deps/native_pkcs11-147d60644989332b.native_pkcs11.58a27a5f3321d193-cgu.0.rcgu.o:native_pkcs11.58a2:(.data+0x1a): undefined reference to `C_GetFunctionList'
          collect2: error: ld returned 1 exit status

  = note: some `extern` functions couldn't be found; some native libraries may need to be installed or have their path specified
  = note: use the `-l` flag to specify native libraries to link
  = note: use the `cargo:rustc-link-lib` directive to specify the native libraries to link with Cargo (see https://doc.rust-lang.org/cargo/reference/build-scripts.html#rustc-link-lib)

error: could not compile `native-pkcs11` (lib) due to 1 previous error

This lead me to believe that there was some issue in how C_GetFunctionList was exported from my crate but when removing the feature "custom-function-list" from the native-pkcs11 dependency and restarting the build following message turns up:

multiple definition of C_GetFunctionList'; `

It seems like there is an issue with the order in which the crates are linked.

Environment

cargo 1.82.0 (8f40fc59f 2024-08-21)
rustc 1.82.0 (f6e511eec 2024-10-15)
x86_64-w64-mingw32-gcc (GCC) 14.1.1 20240607 (Fedora MinGW 14.1.1-3.fc40)

Additional Information

If you need more information I am happy to provide further details.

Thank you in advance.

@brandonweeks
Copy link
Member

We're never tested building with the x86_64-unknown-linux-gnu target, are you able to reproduce the issue with the x86_64-pc-windows-msvc target?

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