-
Notifications
You must be signed in to change notification settings - Fork 13.2k
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
Cannot link with Win32 libraries using the MSVC toolchain #43039
Comments
Your Windows SDK installation is broken and is missing |
Thanks but as I said, |
@Tomcc please try to run console with vcvars32.bat (to have only x32 environment) |
@Tomcc If it couldn't find your Windows SDK at all, it would fail on the first system library in the linker invocation Also, another issue I just noticed is that I see the Rust toolchain you're using is |
Just to add for 64bit environment you can use |
@retep998 Thanks! I tried with the
The problem seems to be that my Thanks again! |
Also a suggestion: |
|
Uhm... I tried on my home machine, and funnily enough, if I try to use |
I think we need to focus exactly what is your issue. If you get error that You can use tool |
@DoumanAsh I agree, it got a bit confused :) Ironically, my home machine runs cargo perfectly through mingw's bash even though I don't have This is the error I get now, which is the same I was getting before:
Still no luck... maybe my VS install is corrupted. |
Looking at your linker line I see |
So, at home, where it works, I do. I'll check tomorrow at work. Thanks! |
Ok... so that folder exists, it's full of files, but... there's no EDIT: Leaving this here if anyone had the same issue eventually: For some reason, on my machine Rust really didn't want to pick the Windows SDK installed by the standalone build tools (which contained I managed to get a UserEnv.lib by fiddling more with the Visual Studio Installer. Apparently, in VS2017 you need a few more packages than what I have - just the SDK isn't enough, you also need "Windows 10 SDK (10.0.15063) for Desktop C++"... otherwise you get only SOME of the files. Amazing! |
@Tomcc Sorry, what did you mean by "just SDK"? |
@pravic when you install VS2017, if you install each component individually it's a mess. You have the choice to install Just installing the package called "SDK" is not enough. Actually those 3 probably aren't enough either, but I have another billion packages installed and adding those made it work :) |
x64 + 10.0.15063 |
Based on @Tomcc comment. |
for my example, maybe the cause is the order of installation for rust and windows SDK. When I repaired SDK, things got! |
I installed Rust on a Windows 10 machine with no compilers or SDKs previously installed and I only needed these two components from the Visual Studio Build Tools installer:
When I open a command prompt with "Visual Studio 2019" -> "x64 Native Tools Command Prompt" on the start menu, I can successfully build Rust applications with "cargo build". |
A few hours later?! Finally! I encountered a fairly common windows10 problem with link.exe. Solution was https://gitanswer.com/rustup-link-exe-problem-on-windows-10-rust-338009649 which lead me to rust-lang/rust#43039 Apparently, this can occur when you decide to download specific components yourself instead of downloading the entire Visual Studio (can't find the exact reference). ```error: linker `link.exe` not found | = note: The system cannot find the file specified. (os error 2) note: the msvc targets depend on the msvc linker but `link.exe` was not found note: please ensure that VS 2013, VS 2015, VS 2017 or VS 2019 was installed with the Visual C++ option error: aborting due to previous error``` * In Visual Studio I needed to download in `Desktop development with C++` MSBuild Tools * Core: C++ Build Tools core feature * C++ 2019 Redistributable Update * C++ core desktop feature * Optional: MSVC v142 - VS 2019 C++ x64/x86 build tools (latest) <- was the last one I didn't have * Windows 10 SDK (10.0.16299.0) Interestingly enough there was never an issue with the missing ```userenv.lib ``` as in the GH issue linked. I believe that's it.
I've switched my environment over from GNU to MSVC, to be able to debug in VSCode.
If I try to build anything, I get an error like this one as soon as some win32-specific library is built:
Other crates fail at
kernel32-sys
or others.I've installed the VS2015 build tools, tried running this in the 2015/17 MSBuild Command Prompt (the one that runs
vcvarsall.bat
) but I get the same error everywhere.I've also tried switching between using VS2017's linker and the linker that came with the Build Tools, and also got no luck.
I know the files it needs are installed, but I have no idea how to let
cargo
start using them.Sorry if it's a known issue, but the similar threads I could find didn't solve my problem.
The text was updated successfully, but these errors were encountered: