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

rustc does not add the LIBPATH for ucrt.lib to the MSVC command line. #27402

Closed
briansmith opened this issue Jul 30, 2015 · 2 comments
Closed

Comments

@briansmith
Copy link
Contributor

When cargo build is used outside of an VS2015 {x86,x64} Native Tools Command Prompt, I receive this error during linking:

rustc: LINK : fatal error LNK1104: cannot open file 'ucrt.lib'

in librustc_trans/back/msvc/mod.rs:

    // The MSVC linker uses the LIB environment variable as the default lookup
    // path for libraries. This environment variable is normally set up by the
    // VS shells, so we only want to start adding our own pieces if it's not
    // set.
    //
    // If we're adding our own pieces, then we need to add two primary
    // directories to the default search path for the linker. The first is in
    // the VS install direcotry and the next is the Windows SDK directory.

When building using the VS2015 toolkit, there is a third path needed: The path to ucrt.lib. On my system, it is C:\Program Files (x86)\Windows Kits\10\lib\10.0.10150.0\ucrt\x64. Here is the full value of the LIB environment variable that vcvarsall.bat sets:

LIB=C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\LIB\amd64;C:\ProgramFiles (x86)\Microsoft Visual Studio 14.0\VC\ATLMFC\LIB\amd64;C:\Program Files (x86)\Windows Kits\10\lib\10.0.10150.0\ucrt\x64;C:\Program Files (x86)\Windows Kits\NETFXSDK\4.6\lib\um\x64;C:\Program Files (x86)\Windows Kits\8.1\lib\winv6.3\um\x64;

Here's the build output, reformatted so every parameter is on its own line:

error: linking with `link.exe` failed: exit code: 1104
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\8.1\Lib\winv6.3\um\x64"
"/NOLOGO"
"/NXCOMPAT"
"/LIBPATH:C:\Users\Example\AppData\Local\Apps\Rust-1.3\bin\rustlib\x86_64-pc-windows-msvc\lib"
"C:\Users\Example\Documents\p\ring\target\debug\build\ring-c7da49b4c8d6e8fe\build_script_build.0.o"
"/OUT:C:\Users\Example\Documents\p\ring\target\debug\build\ring-c7da49b4c8d6e8fe\build_script_build.exe"
"/OPT:REF,ICF"
"/DEBUG"
"/LIBPATH:C:\Users\Example\AppData\Local\Apps\Rust-1.3\bin\rustlib\x86_64-pc-windows-msvc\lib"
"std-74fa456f.lib"
"/LIBPATH:C:\Users\Example\Documents\p\ring\target\debug"
"/LIBPATH:C:\Users\Example\Documents\p\ring\target\debug\deps"
"/LIBPATH:C:\Users\Example\AppData\Local\Apps\Rust-1
.3\bin\rustlib\x86_64-pc-windows-msvc\lib"
"/LIBPATH:C:\Users\Example\Documents\p\ring\.rust\bin\x86_64-pc-windows-msvc"
"/LIBPATH:C:\Users\Example\Documents\p\ring\bin\x86_64-pc-windows-msvc"
"ws2_32.lib"
"userenv.lib"
"advapi32.lib"
"kernel32.lib"
"shell32.lib"
"msvcrt.lib"
"compiler-rt.lib"
note: LINK : fatal error LNK1104: cannot open file 'ucrt.lib'
@briansmith
Copy link
Contributor Author

Also, here's the version information:

C:\Users\Example\Documents\p\rust [master]> rustc --version
rustc 1.3.0-nightly (cb4f102e3 2015-07-22)

C:\Users\Example\Documents\p\rust [master]> cargo --version
cargo 0.4.0-nightly (84ef25d 2015-07-23) (built 2015-07-23)

@alexcrichton
Copy link
Member

Thanks for the report! Support for this was added in #27250 which I believe landed after the nightly you're using, so an update should fix it!

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