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

LINK : fatal error LNK1181: cannot open input file 'legacy_stdio_definitions.lib' #110842

Closed
OwenLu88 opened this issue Apr 26, 2023 · 10 comments
Closed
Labels
O-windows-msvc Toolchain: MSVC, Operating system: Windows

Comments

@OwenLu88
Copy link

I want to compile the rust code with Pycharm, but it's failed. It prompts as follows:
LINK : warning LNK4044: unrecognized option '/NATVIS:C:\Users\lumi.lu.rustup\toolchains\stable-x86_64-pc-windows-msvc\lib\rustlib\etc\intrinsic.natvis'; ignored
LINK : warning LNK4044: unrecognized option '/NATVIS:C:\Users\lumi.lu.rustup\toolchains\stable-x86_64-pc-windows-msvc\lib\rustlib\etc\liballoc.natvis'; ignored
LINK : warning LNK4044: unrecognized option '/NATVIS:C:\Users\lumi.lu.rustup\toolchains\stable-x86_64-pc-windows-msvc\lib\rustlib\etc\libcore.natvis'; ignored
LINK : warning LNK4044: unrecognized option '/NATVIS:C:\Users\lumi.lu.rustup\toolchains\stable-x86_64-pc-windows-msvc\lib\rustlib\etc\libstd.natvis'; ignored
LINK : fatal error LNK1181: cannot open input file 'legacy_stdio_definitions.lib'

What's the legacy_stdio_definitions.lib? I already installed VS2013.
How to fix it?

@albertlarsan68
Copy link
Member

The fix would be to install a newer version of VS, but since the docs say that VS 2013 is supported, it may be a bug.
Can you share the code you are trying to compile, and the commands?

@ChrisDenton
Copy link
Member

This is a very weird coincidence but just four hours ago I posted a PR to libc to stop linking this in Rust's std rust-lang/libc#3226

@Noratrieb Noratrieb added the O-windows Operating system: Windows label Apr 26, 2023
@ChrisDenton ChrisDenton added O-windows-msvc Toolchain: MSVC, Operating system: Windows and removed O-windows Operating system: Windows labels Apr 26, 2023
@ChrisDenton
Copy link
Member

Btw we do still say we support VS 2013 but it isn't tested so we have to rely on user reports for bugs. It's currently on the "extended" stage (security fixes only) of Microsoft's support cycle, which ends next year.

@smaudet
Copy link

smaudet commented Jun 24, 2024

@ChrisDenton I don't know this is necessarily a Visual Studio version issue, there's some other build problem you (we?) are missing.

Trying to fix a completely unrelated build wixtoolset/issues#8173, am having to use explicit package directory includes for the microsoft vc libs everywhere. I am using VS 2022 for this build.

I think it is a compiler bug, but I'm not sure, some other references e.g. ldc-developers/ldc#1085 (comment) mention that there is an issue with the std library being mismanaged.

Possibly the CRT (C-runtime) used should be more explicitly mentioned by the tools, possibly there's some nonsense like the msvc compiler not talking to the linker correctly, however, just wanted to mention this as a possible cause of this build issue.

@ChrisDenton
Copy link
Member

Sorry, I'm unclear how that is related to Rust?

@smaudet
Copy link

smaudet commented Jun 24, 2024

LINK : fatal error LNK1181: cannot open input file 'legacy_stdio_definitions.lib'

The bug is that your compiler can't find your legacy_stdio_definitions.lib, and that is caused by (what I presume must be) a visual studio compiler issue/invalid command line parameters flag.

You were dismissing this issue as relating to Visual Studio 2013, however, this is present in Visual Studio 2022.
Misread what you actually said @ChrisDenton , @albertlarsan68 appears to be the one doing the dismissing.

Unless you were both committing two typos (possible but unlikely), this could be the source of this issue. Not sure how you would resolve, besides generating better include directories, or getting Microsoft to fix (or finding and fixing some issue in your buildchain). 😊

@ChrisDenton
Copy link
Member

We don't use the MSVC compiler only the linker. This issue was that we were passing legacy_stdio_definitions.lib to the linker and VS 2013 doesn't have that import library. That problem was actually fixed, though in another repository so this issue wasn't automatically closed like it should have been.

@smaudet
Copy link

smaudet commented Jun 24, 2024

@ChrisDenton ah - mind linking the fix? I am quite curious what your fix was.

@ChrisDenton
Copy link
Member

The fix was simply not to link legacy_stdio_definitions rust-lang/libc#3226

@ChrisDenton
Copy link
Member

Closing as fixed.

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

5 participants