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

ucrt.lib linkage (again) #32159

Closed
tommiv opened this issue Mar 9, 2016 · 4 comments
Closed

ucrt.lib linkage (again) #32159

tommiv opened this issue Mar 9, 2016 · 4 comments
Labels
O-windows-msvc Toolchain: MSVC, Operating system: Windows

Comments

@tommiv
Copy link

tommiv commented Mar 9, 2016

I'm confused with this actually - fresh installation of Rust on Windows (MSVC ABI) fails to link hello world. I found this ticket but it's pretty old and it's closed, so I assume it was fixed. Let's go to the explanation.

This is the simple hello world (main.rs):

fn main() {
    println!("Hello, world!")
}

there is no any other files in project, no cargo setup or something.

Using rustc main.rs I'm getting this error:

error: linking with `link.exe` failed: exit code: 1104
note: LINK : fatal error LNK1104: cannot open file 'ucrt.lib'

Based on the ticket above I provided compiler the path to ucrt.lib with
rustc -L "C:\Program Files (x86)\Windows Kits\10\Lib\10.0.10240.0\ucrt\x64" main.rs and it works just fine.

Additional info:

  • Rust is rustc 1.8.0-beta.1 (facbfdd71 2016-03-02), MSVC ABI. (but error is the same with 1.7 stable. I didn't try nightly build).
  • OS is Windows 10 Pro, x64
  • Visual Studio is 2015 with all available patches installed.
  • Rust /bin/ directory have added to the PATH environment variable.

So. Am I missed some installation steps or it's a problem with my environment?

UPD: Just tried to run compiler from VS developer command prompt and got the other error: note: msvcrt.lib(chkstk.obj) : fatal error LNK1112: module machine type 'X86' conflicts with target machine type 'x64' and I have no clue how I can to change the architecture. I don't see a separate x64 version of VS dev cmd.

UPD2: I investigated further and found that linker message contains this command line option among the others: "/LIBPATH:C:\\Program Files (x86)\\Windows Kits\\10\\Lib\\10.0.10586.0\\ucrt\\x64". The weird part here that while my system has 10.0.10586.0 there is NO ucrt folder in it. But it has 10.0.10150.0/ucrt/* and 10.0.10240.0/ucrt/* folders.

UPD3: Since this ucrt folder obviously is the part of the Windows 10 SDK, I installed it manually from official page with ALL available checkboxes checked. Now I have 10.0.10586.0/ucrt/* folders and compilation works without any additional steps. In the end I'm not sure should I close this ticket or such situation can be handled by installer or rustc itself. Minor clarification: I DON'T installed Win 10 SDK manually before, 10.0.10150.0 version was installed either as dependency for some packages I've used in development or with VS updates. Somehow this installation was not full and didn't include this ucrt libraries.

@retep998
Copy link
Member

Thanks for this information, in particular UPD2 was very useful. I will add a sanity check to #31158 to make sure the UCRT candidate is viable which should fix this problem for anyone else who runs into this.

@alexcrichton alexcrichton added the O-windows-msvc Toolchain: MSVC, Operating system: Windows label Mar 10, 2016
@carlosdiez
Copy link

I ran into the same issue, I have installed:

  • Visual Studio 2015 Community
  • Windows 7 Professional (x64) SP1
  • Rust 1.8.0

The folder C:\Program Files (x86)\Windows Kits\10\Lib\10.0.10586.0 did not contain ucrt.
I copied ucrt folder from the previous version C:\Program Files (x86)\Windows Kits\10\Lib\10.0.10240.0 and it worked for me.

Not the best way of fixing it, I guess the proper way should be to rust to use a previous version of the windows SDK or just installing the latest version (Windows 10 SDK currently)

@bors bors closed this as completed in a1b33b4 Jul 2, 2016
@romanlevin
Copy link

romanlevin commented May 28, 2018

Ran into a similar error:

error: linking with `C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.10.25017\bin\HostX64\x64\link.exe` failed: exit code: 1104
  |
  = note: "C:\\Program Files (x86)\\Microsoft Visual Studio\\2017\\Community\\VC\\Tools\\MSVC\\14.10.25017\\bin\\HostX64\\x64\\link.exe" "/NOLOGO" "/NXCOMPAT" "/LIBPATH:F:\\Active Users\\Roman\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib" "F:\\Active Users\\Roman\\mandelbrot-rs\\target\\debug\\deps\\num_derive-26cf2a6f8d07d9a9.num_derive0.rcgu.o" "F:\\Active Users\\Roman\\mandelbrot-rs\\target\\debug\\deps\\num_derive-26cf2a6f8d07d9a9.num_derive1.rcgu.o" "F:\\Active Users\\Roman\\mandelbrot-rs\\target\\debug\\deps\\num_derive-26cf2a6f8d07d9a9.num_derive10.rcgu.o" "F:\\Active Users\\Roman\\mandelbrot-rs\\target\\debug\\deps\\num_derive-26cf2a6f8d07d9a9.num_derive11.rcgu.o" "F:\\Active Users\\Roman\\mandelbrot-rs\\target\\debug\\deps\\num_derive-26cf2a6f8d07d9a9.num_derive12.rcgu.o" "F:\\Active Users\\Roman\\mandelbrot-rs\\target\\debug\\deps\\num_derive-26cf2a6f8d07d9a9.num_derive13.rcgu.o" "F:\\Active Users\\Roman\\mandelbrot-rs\\target\\debug\\deps\\num_derive-26cf2a6f8d07d9a9.num_derive14.rcgu.o" "F:\\Active Users\\Roman\\mandelbrot-rs\\target\\debug\\deps\\num_derive-26cf2a6f8d07d9a9.num_derive15.rcgu.o" "F:\\Active Users\\Roman\\mandelbrot-rs\\target\\debug\\deps\\num_derive-26cf2a6f8d07d9a9.num_derive2.rcgu.o" "F:\\Active Users\\Roman\\mandelbrot-rs\\target\\debug\\deps\\num_derive-26cf2a6f8d07d9a9.num_derive3.rcgu.o" "F:\\Active Users\\Roman\\mandelbrot-rs\\target\\debug\\deps\\num_derive-26cf2a6f8d07d9a9.num_derive4.rcgu.o" "F:\\Active Users\\Roman\\mandelbrot-rs\\target\\debug\\deps\\num_derive-26cf2a6f8d07d9a9.num_derive5.rcgu.o" "F:\\Active Users\\Roman\\mandelbrot-rs\\target\\debug\\deps\\num_derive-26cf2a6f8d07d9a9.num_derive6.rcgu.o" "F:\\Active Users\\Roman\\mandelbrot-rs\\target\\debug\\deps\\num_derive-26cf2a6f8d07d9a9.num_derive7.rcgu.o" "F:\\Active Users\\Roman\\mandelbrot-rs\\target\\debug\\deps\\num_derive-26cf2a6f8d07d9a9.num_derive8.rcgu.o" "F:\\Active Users\\Roman\\mandelbrot-rs\\target\\debug\\deps\\num_derive-26cf2a6f8d07d9a9.num_derive9.rcgu.o" "/OUT:F:\\Active Users\\Roman\\mandelbrot-rs\\target\\debug\\deps\\num_derive-26cf2a6f8d07d9a9.dll" "/DEF:F:\\ACTIVE~1\\Roman\\AppData\\Local\\Temp\\rustc.ELoZUlCEMZoR\\lib.def" "F:\\Active Users\\Roman\\mandelbrot-rs\\target\\debug\\deps\\num_derive-26cf2a6f8d07d9a9.crate.metadata.rcgu.o" "F:\\Active Users\\Roman\\mandelbrot-rs\\target\\debug\\deps\\num_derive-26cf2a6f8d07d9a9.crate.allocator.rcgu.o" "/OPT:REF,NOICF" "/DEBUG" "/NATVIS:F:\\Active Users\\Roman\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\etc\\intrinsic.natvis" "/NATVIS:F:\\Active Users\\Roman\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\etc\\liballoc.natvis" "/NATVIS:F:\\Active Users\\Roman\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\etc\\libcore.natvis" "/LIBPATH:F:\\Active Users\\Roman\\mandelbrot-rs\\target\\debug\\deps" "/LIBPATH:F:\\Active Users\\Roman\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib" "F:\\Active Users\\Roman\\mandelbrot-rs\\target\\debug\\deps\\libsyn-5cf75470db38aa30.rlib" "F:\\Active Users\\Roman\\mandelbrot-rs\\target\\debug\\deps\\libquote-62935cfb263bea69.rlib" "F:\\Active Users\\Roman\\mandelbrot-rs\\target\\debug\\deps\\libproc_macro2-2c395399edf6f458.rlib" "F:\\Active Users\\Roman\\mandelbrot-rs\\target\\debug\\deps\\libunicode_xid-4611d062b1d773c0.rlib" "/LIBPATH:F:\\Active Users\\Roman\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib" "proc_macro-1f431d761952eacf.dll.lib" "/LIBPATH:F:\\Active Users\\Roman\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib" "syntax-c4a428491fc49b8f.dll.lib" "/LIBPATH:F:\\Active Users\\Roman\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib" "rustc_errors-5b01c9a7974f0222.dll.lib" "/LIBPATH:F:\\Active Users\\Roman\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib" "syntax_pos-09170bc016e0b11a.dll.lib" "/LIBPATH:F:\\Active Users\\Roman\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib" "rustc_data_structures-f974a5ad0e93670e.dll.lib" "/LIBPATH:F:\\Active Users\\Roman\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib" "serialize-2eb0aeb35010f869.dll.lib" "/LIBPATH:F:\\Active Users\\Roman\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib" "rustc_cratesio_shim-2e9a42f968785601.dll.lib" "/LIBPATH:F:\\Active Users\\Roman\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib" "std-81327c94ecbc69b1.dll.lib" "F:\\Active Users\\Roman\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\libcompiler_builtins-e8d853735a158029.rlib" "opengl32.lib" "kernel32.lib" "setupapi.lib" "msimg32.lib" "credui.lib" "winspool.lib" "user32.lib" "gdi32.lib" "secur32.lib" "dbghelp.lib" "advapi32.lib" "advapi32.lib" "ws2_32.lib" "userenv.lib" "shell32.lib" "msvcrt.lib" "/DLL" "/IMPLIB:F:\\Active Users\\Roman\\mandelbrot-rs\\target\\debug\\deps\\num_derive-26cf2a6f8d07d9a9.dll.lib"
  = note: LINK : fatal error LNK1104: cannot open file 'F:\Active Users\Roman\mandelbrot-rs\target\debug\deps\num_derive-26cf2a6f8d07d9a9.dll'
rustc 1.26.0 (a77568041 2018-05-07)

These are the VC tools I have installed:
image

@romanlevin
Copy link

Okay, this seems to have been caused by RLS?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
O-windows-msvc Toolchain: MSVC, Operating system: Windows
Projects
None yet
Development

No branches or pull requests

6 participants
@alexcrichton @romanlevin @retep998 @tommiv @carlosdiez and others