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

Cannot link with Win32 libraries using the MSVC toolchain #43039

Closed
Tomcc opened this issue Jul 3, 2017 · 19 comments

Comments

Projects
None yet
7 participants
@Tomcc
Copy link

commented Jul 3, 2017

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:

C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise>cargo install cargo-update
    Updating registry `https://github.com/rust-lang/crates.io-index`
  Installing cargo-update v1.1.1
   Compiling winapi v0.2.8
   Compiling unicode-width v0.1.4
   Compiling vcpkg v0.2.2
   Compiling utf8-ranges v1.0.0
   Compiling bitflags v0.9.1
   Compiling lazy_static v0.2.8
   Compiling libc v0.2.24
   Compiling winapi-build v0.1.1
   Compiling array_tool v0.4.0
   Compiling tabwriter v1.0.3
   Compiling pkg-config v0.3.9
   Compiling gcc v0.3.51
   Compiling advapi32-sys v0.2.0
   Compiling unicode-segmentation v1.1.0
error: linking with `link.exe` failed: exit code: 1181
  |
  = note: "C:\\Program Files (x86)\\Microsoft Visual Studio\\2017\\Enterprise\\VC\\Tools\\MSVC\\14.10.25017\\bin\\HostX86\\x86\\link.exe" "/NOLOGO" "/NXCOMPAT" "/LIBPATH:C:\\Users\\tochecch\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib" "C:\\Users\\tochecch\\AppData\\Local\\Temp\\cargo-install.abPCagDNmi5f\\release\\build\\advapi32-sys-a27db48c38a94830\\build_script_build-a27db48c38a94830.0.o" "/OUT:C:\\Users\\tochecch\\AppData\\Local\\Temp\\cargo-install.abPCagDNmi5f\\release\\build\\advapi32-sys-a27db48c38a94830\\build_script_build-a27db48c38a94830.exe" "/OPT:REF,ICF" "/DEBUG" "/LIBPATH:C:\\Users\\tochecch\\AppData\\Local\\Temp\\cargo-install.abPCagDNmi5f\\release\\deps" "/LIBPATH:C:\\Users\\tochecch\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib" "C:\\Users\\tochecch\\AppData\\Local\\Temp\\cargo-install.abPCagDNmi5f\\release\\deps\\libbuild-cc558114ba27a576.rlib" "C:\\Users\\tochecch\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\libstd-0a78323911070f99.rlib" "C:\\Users\\tochecch\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\librand-c279a51d66700350.rlib" "C:\\Users\\tochecch\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\libcollections-d7bf31a4ca1ea637.rlib" "C:\\Users\\tochecch\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\libstd_unicode-d367c3ba0db49600.rlib" "C:\\Users\\tochecch\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\libpanic_unwind-2d4bf02140c11dcb.rlib" "C:\\Users\\tochecch\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\libunwind-add7a84d7e82d084.rlib" "C:\\Users\\tochecch\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\liblibc-84688accbc86d6b7.rlib" "C:\\Users\\tochecch\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\liballoc-fe2e68b21f0bdd7a.rlib" "C:\\Users\\tochecch\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\liballoc_system-7fc0381594c93f56.rlib" "C:\\Users\\tochecch\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\libcore-ea9d77e7c23fe65c.rlib" "C:\\Users\\tochecch\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\libcompiler_builtins-91b619d34dd1f5aa.rlib" "advapi32.lib" "ws2_32.lib" "userenv.lib" "shell32.lib" "msvcrt.lib"
  = note: LINK : fatal error LNK1181: cannot open input file 'userenv.lib'


error: aborting due to previous error

error: Could not compile `advapi32-sys`.
Build failed, waiting for other jobs to finish...

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.

@retep998

This comment has been minimized.

Copy link
Member

commented Jul 5, 2017

Your Windows SDK installation is broken and is missing userenv.lib. Please repair your Windows SDK installation, or reinstall it.

@Tomcc

This comment has been minimized.

Copy link
Author

commented Jul 5, 2017

Thanks but as I said, userenv.lib is definitely in my installation folder - I also repaired it several times but it didn't help.

@DoumanAsh

This comment has been minimized.

Copy link

commented Jul 5, 2017

@Tomcc please try to run console with vcvars32.bat (to have only x32 environment)
cargo should definitely work just fine with 2015/2017 build tools, but if you run from console environment you need to ensure to load correct architecture (though wrong arch should not lead to missing lib)

@retep998

This comment has been minimized.

Copy link
Member

commented Jul 5, 2017

@Tomcc If it couldn't find your Windows SDK at all, it would fail on the first system library in the linker invocation advapi32.lib, not userenv.lib. You might see a userenv.lib in your Windows SDK, but you might be looking in a different Windows SDK than the one that is being used, or perhaps the wrong architecture for that Windows SDK. Check what the exact Windows SDK path being used is by looking in your LIB environment variable, or the respective /LIBPATH argument being passed to the linker by rustc, and then double check that userenv.lib is in fact in that specific Windows SDK folder.

Also, another issue I just noticed is that I see the Rust toolchain you're using is x86_64-pc-windows-msvc which is the 64bit toolchain while the linker you're invoking is HostX86\\x86\\link.exe which is the 32bit linker. Please ensure that the VC++ command prompt or vcvars bat file that you are using matches the architecture of your Rust toolchain, otherwise linking will fail.

@DoumanAsh

This comment has been minimized.

Copy link

commented Jul 5, 2017

Just to add for 64bit environment you can use vcvars64.bat

@Tomcc

This comment has been minimized.

Copy link
Author

commented Jul 6, 2017

@retep998 Thanks! I tried with the VS2015 x64 Native Tools Command Prompt, which uses the right version of the linker. I also ran vcvarsall and vcvars64 to make sure.
It didn't work though:

C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC>vcvarsall

C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC>vcvars64
C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC>cargo install cargo-update
    Updating registry `https://github.com/rust-lang/crates.io-index`
  Installing cargo-update v1.1.1
   Compiling void v1.0.2
   Compiling lazy_static v0.2.8
   Compiling bitflags v0.9.1
   Compiling regex-syntax v0.4.1
   Compiling quote v0.3.15
   Compiling json v0.11.8
   Compiling ansi_term v0.9.0
   Compiling unicode-segmentation v1.1.0
   Compiling vec_map v0.8.0
   Compiling vcpkg v0.2.2
   Compiling percent-encoding v1.0.0
   Compiling matches v0.1.6
   Compiling gcc v0.3.51
   Compiling serde v1.0.9
   Compiling pkg-config v0.3.9
   Compiling unicode-bidi v0.3.3
   Compiling semver-parser v0.7.0
   Compiling winapi v0.2.8
   Compiling unicode-width v0.1.4
   Compiling unreachable v1.0.0
   Compiling tabwriter v1.0.3
   Compiling thread_local v0.3.4
   Compiling libc v0.2.24
   Compiling winapi-build v0.1.1
   Compiling semver v0.6.0
   Compiling rand v0.3.15
   Compiling memchr v1.0.1
   Compiling aho-corasick v0.6.3
   Compiling advapi32-sys v0.2.0
   Compiling unicode-xid v0.0.4
   Compiling strsim v0.6.0
error: linking with `link.exe` failed: exit code: 1181
  |
  = note: "C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\VC\\BIN\\amd64\\link.exe" "/NOLOGO" "/NXCOMPAT" "/LIBPATH:C:\\Users\\tochecch\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib" "C:\\Users\\tochecch\\AppData\\Local\\Temp\\cargo-install.zfSmkQtblLRp\\release\\build\\advapi32-sys-a27db48c38a94830\\build_script_build-a27db48c38a94830.0.o" "/OUT:C:\\Users\\tochecch\\AppData\\Local\\Temp\\cargo-install.zfSmkQtblLRp\\release\\build\\advapi32-sys-a27db48c38a94830\\build_script_build-a27db48c38a94830.exe" "/OPT:REF,ICF" "/DEBUG" "/LIBPATH:C:\\Users\\tochecch\\AppData\\Local\\Temp\\cargo-install.zfSmkQtblLRp\\release\\deps" "/LIBPATH:C:\\Users\\tochecch\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib" "C:\\Users\\tochecch\\AppData\\Local\\Temp\\cargo-install.zfSmkQtblLRp\\release\\deps\\libbuild-cc558114ba27a576.rlib" "C:\\Users\\tochecch\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\libstd-0a78323911070f99.rlib" "C:\\Users\\tochecch\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\librand-c279a51d66700350.rlib" "C:\\Users\\tochecch\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\libcollections-d7bf31a4ca1ea637.rlib" "C:\\Users\\tochecch\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\libstd_unicode-d367c3ba0db49600.rlib" "C:\\Users\\tochecch\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\libpanic_unwind-2d4bf02140c11dcb.rlib" "C:\\Users\\tochecch\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\libunwind-add7a84d7e82d084.rlib" "C:\\Users\\tochecch\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\liblibc-84688accbc86d6b7.rlib" "C:\\Users\\tochecch\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\liballoc-fe2e68b21f0bdd7a.rlib" "C:\\Users\\tochecch\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\liballoc_system-7fc0381594c93f56.rlib" "C:\\Users\\tochecch\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\libcore-ea9d77e7c23fe65c.rlib" "C:\\Users\\tochecch\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\libcompiler_builtins-91b619d34dd1f5aa.rlib" "advapi32.lib" "ws2_32.lib" "userenv.lib" "shell32.lib" "msvcrt.lib"
  = note: LINK : fatal error LNK1181: cannot open input file 'userenv.lib'


error: aborting due to previous error

error: Could not compile `advapi32-sys`.
Build failed, waiting for other jobs to finish...

The problem seems to be that my LIB env variable is not set at all, and that there is no /LIBPATH argument for the Windows SDK at all in that command line!
That's something... do you have an example of how it should look like?
I thought it would set itself up automatically... it did at home, and there it works off the normal command line.

Thanks again!

@Tomcc

This comment has been minimized.

Copy link
Author

commented Jul 6, 2017

Also a suggestion: cargo could warn you if you try to use any link.exe that's not the MSVC linker... I had that issue at home and it made me waste quite a lot of time :)

@retep998

This comment has been minimized.

Copy link
Member

commented Jul 6, 2017

The problem seems to be that my LIB env variable is not set at all, and that there is no /LIBPATH argument for the Windows SDK at all in that command line!

LIB is only set inside a configured environment, such as after you invoke one of the vcvars bat files. It's typically not going to be set when you're in a brand new console. Meanwhile /LIBPATH for the Windows SDK will only be passed by rustc to the linker when you're not inside a configured environment. Either one or the other will be there.

@Tomcc

This comment has been minimized.

Copy link
Author

commented Jul 6, 2017

Uhm... I tried on my home machine, and funnily enough, if I try to use VS2015 x64 Native Tools Command Prompt I actually get an error that vcvarsall.bat could not be found. And then it works anyway!
On this machine cargo it seems to be able to link on any cmd or even MinGW bash... I'm sure that vcvars* shouldn't be needed. No idea what the difference would be though.
Is there any log/verbose output/anything that can help?

@DoumanAsh

This comment has been minimized.

Copy link

commented Jul 6, 2017

I think we need to focus exactly what is your issue.
Is your problem running cargo/rust from VS2015 prompt?

If you get error that vcvarsall.bat is missing, then you definitely isn't going to have needed environment variables.
If you have issues with even prompt it sounds like a problem of your installation.
Did you check that your home machine has this vcvarsall.bat?

You can use tool Everything to quickly index all files. It is portable so you can grab just exe here https://www.voidtools.com/

@Tomcc

This comment has been minimized.

Copy link
Author

commented Jul 13, 2017

@DoumanAsh I agree, it got a bit confused :)
So, the problem is that cargo and rust cannot link any win32-specific crate from any console.
I've tried in Git's Bash, in cmd, in the VS2015 prompt (as recommended here), I made sure that vcvarsall.bat was run (I have it and it works), and made sure that the right linker was called;
I'm also sure that I have the libraries I need.

Ironically, my home machine runs cargo perfectly through mingw's bash even though I don't have vcvarsall.bat and the VS2015 Native Console doesn't work... so whatever it is, I doubt that vcvarsall.bat is actually needed.

This is the error I get now, which is the same I was getting before:

    Updating registry `https://github.com/rust-lang/crates.io-index`
  Installing cargo-update v1.1.1
   Compiling semver-parser v0.7.0
   Compiling json v0.11.8
   Compiling libc v0.2.26
   Compiling winapi-build v0.1.1
   Compiling winapi v0.2.8
   Compiling void v1.0.2
   Compiling lazy_static v0.2.8
   Compiling utf8-ranges v1.0.0
   Compiling unreachable v1.0.0
   Compiling vcpkg v0.2.2
   Compiling serde v1.0.10
   Compiling thread_local v0.3.4
   Compiling percent-encoding v1.0.0
   Compiling array_tool v0.4.0
   Compiling unicode-xid v0.0.4
   Compiling memchr v1.0.1
   Compiling synom v0.11.3
   Compiling gcc v0.3.51
   Compiling semver v0.6.0
   Compiling aho-corasick v0.6.3
   Compiling regex-syntax v0.4.1
   Compiling vec_map v0.8.0
   Compiling unicode-segmentation v1.1.0
   Compiling ansi_term v0.9.0
   Compiling matches v0.1.6
   Compiling strsim v0.6.0
   Compiling unicode-bidi v0.3.4
   Compiling kernel32-sys v0.2.2
error: linking with `link.exe` failed: exit code: 1181
  |
  = note: "C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\VC\\bin\\amd64\\link.exe" "/LIBPATH:C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\VC\\lib\\amd64" "/LIBPATH:C:\\Program Files (x86)\\Windows Kits\\10\\lib\\10.0.15063.0\\ucrt\\x64" "/LIBPATH:C:\\Program Files (x86)\\Windows Kits\\10\\lib\\10.0.15063.0\\um\\x64" "/NOLOGO" "/NXCOMPAT" "/LIBPATH:C:\\Users\\tochecch\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib" "C:\\Users\\tochecch\\AppData\\Local\\Temp\\cargo-install.LWP8drBtUD59\\release\\build\\kernel32-sys-5ee1259db1228dbc\\build_script_build-5ee1259db1228dbc.0.o" "/OUT:C:\\Users\\tochecch\\AppData\\Local\\Temp\\cargo-install.LWP8drBtUD59\\release\\build\\kernel32-sys-5ee1259db1228dbc\\build_script_build-5ee1259db1228dbc.exe" "/OPT:REF,ICF" "/DEBUG" "/LIBPATH:C:\\Users\\tochecch\\AppData\\Local\\Temp\\cargo-install.LWP8drBtUD59\\release\\deps" "/LIBPATH:C:\\Users\\tochecch\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib" "C:\\Users\\tochecch\\AppData\\Local\\Temp\\cargo-install.LWP8drBtUD59\\release\\deps\\libbuild-cc558114ba27a576.rlib" "C:\\Users\\tochecch\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\libstd-0a78323911070f99.rlib" "C:\\Users\\tochecch\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\librand-c279a51d66700350.rlib" "C:\\Users\\tochecch\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\libcollections-d7bf31a4ca1ea637.rlib" "C:\\Users\\tochecch\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\libstd_unicode-d367c3ba0db49600.rlib" "C:\\Users\\tochecch\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\libpanic_unwind-2d4bf02140c11dcb.rlib" "C:\\Users\\tochecch\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\libunwind-add7a84d7e82d084.rlib" "C:\\Users\\tochecch\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\liblibc-84688accbc86d6b7.rlib" "C:\\Users\\tochecch\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\liballoc-fe2e68b21f0bdd7a.rlib" "C:\\Users\\tochecch\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\liballoc_system-7fc0381594c93f56.rlib" "C:\\Users\\tochecch\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\libcore-ea9d77e7c23fe65c.rlib" "C:\\Users\\tochecch\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\libcompiler_builtins-91b619d34dd1f5aa.rlib" "advapi32.lib" "ws2_32.lib" "userenv.lib" "shell32.lib" "msvcrt.lib"
  = note: LINK : fatal error LNK1181: cannot open input file 'userenv.lib'


error: aborting due to previous error

error: Could not compile `kernel32-sys`.
Build failed, waiting for other jobs to finish...

Still no luck... maybe my VS install is corrupted.

@retep998

This comment has been minimized.

Copy link
Member

commented Jul 13, 2017

Looking at your linker line I see "/LIBPATH:C:\\Program Files (x86)\\Windows Kits\\10\\lib\\10.0.15063.0\\um\\x64". Can you please take a look in specifically C:\Program Files (x86)\Windows Kits\10\lib\10.0.15063.0\um\x64 and double check that there is a userenv.lib there?

@Tomcc

This comment has been minimized.

Copy link
Author

commented Jul 14, 2017

So, at home, where it works, I do. I'll check tomorrow at work. Thanks!

@Tomcc

This comment has been minimized.

Copy link
Author

commented Jul 14, 2017

Ok... so that folder exists, it's full of files, but... there's no userenv.lib there! I should have checked before... that's definitely the problem.
Not Rust related, you can close if you want.
However, do you have any idea of why my Windows SDK might be broken? I tried repairing it using the VS Installer but I had no luck.

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 userenv.lib); it might have to do with the fact that I had VS2017 installed already.

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!
This might still be kinda rust's fault for not preferring 2015's SDK and/or not letting me choose which SDK to use, but I have no idea.

@Tomcc Tomcc closed this Jul 14, 2017

@pravic

This comment has been minimized.

Copy link
Contributor

commented Jul 21, 2017

just the SDK isn't enough

@Tomcc Sorry, what did you mean by "just SDK"?

@Tomcc

This comment has been minimized.

Copy link
Author

commented Jul 23, 2017

@pravic when you install VS2017, if you install each component individually it's a mess.

You have the choice to install Windows 10 SDK (10.0.15063). However, installing only that one isn't enough! You also have to install Windows 10 SDK (10.0.15063) for Desktop C++ x86 and x64 and VC++ 2017 v141 toolset (x86, x64).

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 :)

@Voskrese

This comment has been minimized.

Copy link

commented Jul 23, 2017

call "c:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat"


    "c:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" [option]
  or
    "c:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" [option] store
  or
    "c:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" [option] [version number]
  or
    "c:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" [option] store [version number]
where [option] is: x86 | amd64 | arm | x86_amd64 | x86_arm | amd64_x86 | amd64_arm
where [version number] is either the full Windows 10 SDK version number or "8.1" to use the windows 8.1 SDK
:
The store parameter sets environment variables to support
  store (rather than desktop) development.
:
For example:
    "c:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" x86_amd64
    "c:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" x86_arm store
    "c:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" x86_amd64 10.0.10240.0
    "c:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" x86_arm store 10.0.10240.0
    "c:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" x64 8.1
    "c:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" x64 store 8.1
:
Please make sure either Visual Studio or C++ Build SKU is installed.

x64 + 10.0.15063
call "c:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" x86_amd64 10.0.15063

raidenfreeman added a commit to raidenfreeman/book that referenced this issue Aug 8, 2018

Added info on Windows installation dependencies
Currently, if you follow the installation instructions, you vaguely get instructed to install VC++. If you only install VC++ 17 (on Windows 10 at least), `rustc` can't find a proper linker ([see here](rust-lang/rustup.rs#1003 (comment)))

There is a number of issues with the rust compiler not being able to find a linker on Windows, for the Hello World tutorial ([example 1](rust-lang/rustup.rs#1455), [example 2](rust-lang/rustup.rs#1363), [example 3](rust-lang/rust#43039)). Maybe this clarification will help.

raidenfreeman added a commit to raidenfreeman/book that referenced this issue Aug 8, 2018

Added info on Windows installation dependencies (2018 ed)
Currently, if you follow the installation instructions, you vaguely get instructed to install VC++. If you only install VC++ 17 (on Windows 10 at least), `rustc` can't find a proper linker ([see here](rust-lang/rustup.rs#1003 (comment)))

There is a number of issues with the rust compiler not being able to find a linker on Windows, for the Hello World tutorial ([example 1](rust-lang/rustup.rs#1455), [example 2](rust-lang/rustup.rs#1363), [example 3](rust-lang/rust#43039)). Maybe this clarification will help.
@houssemFat-DDF

This comment has been minimized.

Copy link

commented Mar 12, 2019

Based on @Tomcc comment.
We need to install other sdk tools for windows 10. Below the list of VS C++ requirements for running the hello word example

image

@JamesChan

This comment has been minimized.

Copy link

commented Jun 13, 2019

for my example, maybe the cause is the order of installation for rust and windows SDK. When I repaired SDK, things got!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.