-
Notifications
You must be signed in to change notification settings - Fork 527
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
Why does windows-targets have compiled static libraries? #2443
Comments
Hi @rodrigocfd, those are import libraries not static libraries. The baseline folder is used to detect import library differences--it's less cumbersome than trying to diff a binary blob. See also #2132. Closing as there's nothing actionable here but feel free to keep the discussion going/ask any follow up questions. |
To put it another way, your example has a dependency: #[link(name = "user32")] You're depending on the target specific import library "user32.lib". These libraries are usually managed by the Visual Studio or the Windows SDK installer. Rust is somewhat "smart" and will attempt to locate these kinds of dependencies for you. Rather than having to find arbitrary import libraries from arbitrary SDK versions, the correct import libraries are distributed with windows-rs. This bundles all the required imports into one lib file for your target and makes sure there are no missing imports for your version of windows-rs. The windows-targets crate is just a way to manage using the correct library for the target. |
Thanks for the answers, guys. Let me see if I got this right: if I'm using MSVC, when writing So, windows-targets provides its own user32.lib, so I depend on no one else's. Is that it? |
Yep! I should also mention a new feature coming soon is |
And the |
Now I'm wondering: why is it so bad to depend on the import libs provided by the toolchains? I mean, all those C and C++ programs are being built with them for decades. Did you guys ever come across some situation where they didn't work as expected? |
One reason is that the crate provides access to APIs that may not have corresponding import libraries in the Windows SDK. |
This pretty much what I wanted to know. @riverar, @ChrisDenton and @kennykerr, thank you very much. |
This issue is just a question.
The windows crate depends on windows-targets crate for linker support. And windows-targets depends on internal crates which vary according to the platform. These crates have compiled static libraries like this one, which are passed to the linker via
cargo:rustc-link-search=native={LIB_DIR}
.Now I'm wondering:
I'm curious because the program below, with zero dependencies, works fine:
The text was updated successfully, but these errors were encountered: