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

MSVC link error: LNK1181: cannot open input file 'stdc++.lib' when building on Windows 10 #11602

Closed
HMaker opened this issue Sep 14, 2024 · 5 comments · Fixed by #11603
Closed
Labels
waiting-on-reporter Issue is waiting on a reply from the reporter. It will be automatically cloesd if there is no reply.

Comments

@HMaker
Copy link

HMaker commented Sep 14, 2024

I am trying to build cryptography on Windows 10 from the main branch (version 44.0.0.dev1) but I am getting the following linker error

warning: cargo:rustc-check-cfg requires -Zcheck-cfg=output flag
   Compiling cryptography-x509-verification v0.1.0 (D:\Users\user\projects\cryptography\src\rust\cryptography-x509-verification)
   Compiling cryptography-keepalive v0.1.0 (D:\Users\user\projects\cryptography\src\rust\cryptography-keepalive)
warning: cargo:rustc-check-cfg requires -Zcheck-cfg=output flag
error: linking with `link.exe` failed: exit code: 1181
  |
  = note: "D:\\Program Files\\Visual Studio 2022\\VC\\Tools\\MSVC\\14.33.31629\\bin\\HostX64\\x64\\link.exe" "/DEF:C:\\Users\\heral\\AppData\\Local\\Temp\\rustceX1swW\\lib.def" "/NOLOGO" "C:\\Users\\heral\\AppData\\Local\\Temp\\rustceX1swW\\symbols.o" "D:\\Users\\user\\projects\\cryptography\\src\\rust\\target\\release\\deps\\cryptography_rust.cryptography_rust.1d9dd0dd7741fcb4-cgu.00.rcgu.o" "D:\\Users\\user\\projects\\cryptography\\src\\rust\\target\\release\\deps\\cryptography_rust.cryptography_rust.1d9dd0dd7741fcb4-cgu.01.rcgu.o" "D:\\Users\\user\\projects\\cryptography\\src\\rust\\target\\release\\deps\\cryptography_rust.cryptography_rust.1d9dd0dd7741fcb4-cgu.02.rcgu.o" "D:\\Users\\user\\projects\\cryptography\\src\\rust\\target\\release\\deps\\cryptography_rust.cryptography_rust.1d9dd0dd7741fcb4-cgu.03.rcgu.o" "D:\\Users\\user\\projects\\cryptography\\src\\rust\\target\\release\\deps\\cryptography_rust.cryptography_rust.1d9dd0dd7741fcb4-cgu.04.rcgu.o" "D:\\Users\\user\\projects\\cryptography\\src\\rust\\target\\release\\deps\\cryptography_rust.cryptography_rust.1d9dd0dd7741fcb4-cgu.05.rcgu.o" "D:\\Users\\user\\projects\\cryptography\\src\\rust\\target\\release\\deps\\cryptography_rust.cryptography_rust.1d9dd0dd7741fcb4-cgu.06.rcgu.o" "D:\\Users\\user\\projects\\cryptography\\src\\rust\\target\\release\\deps\\cryptography_rust.cryptography_rust.1d9dd0dd7741fcb4-cgu.07.rcgu.o" "D:\\Users\\user\\projects\\cryptography\\src\\rust\\target\\release\\deps\\cryptography_rust.cryptography_rust.1d9dd0dd7741fcb4-cgu.08.rcgu.o" "D:\\Users\\user\\projects\\cryptography\\src\\rust\\target\\release\\deps\\cryptography_rust.cryptography_rust.1d9dd0dd7741fcb4-cgu.09.rcgu.o" "D:\\Users\\user\\projects\\cryptography\\src\\rust\\target\\release\\deps\\cryptography_rust.cryptography_rust.1d9dd0dd7741fcb4-cgu.10.rcgu.o" "D:\\Users\\user\\projects\\cryptography\\src\\rust\\target\\release\\deps\\cryptography_rust.cryptography_rust.1d9dd0dd7741fcb4-cgu.11.rcgu.o" "D:\\Users\\user\\projects\\cryptography\\src\\rust\\target\\release\\deps\\cryptography_rust.cryptography_rust.1d9dd0dd7741fcb4-cgu.12.rcgu.o" "D:\\Users\\user\\projects\\cryptography\\src\\rust\\target\\release\\deps\\cryptography_rust.cryptography_rust.1d9dd0dd7741fcb4-cgu.13.rcgu.o" "D:\\Users\\user\\projects\\cryptography\\src\\rust\\target\\release\\deps\\cryptography_rust.cryptography_rust.1d9dd0dd7741fcb4-cgu.14.rcgu.o" "D:\\Users\\user\\projects\\cryptography\\src\\rust\\target\\release\\deps\\cryptography_rust.cryptography_rust.1d9dd0dd7741fcb4-cgu.15.rcgu.o" "D:\\Users\\user\\projects\\cryptography\\src\\rust\\target\\release\\deps\\cryptography_rust.mtwln69gxk5ysk2.rcgu.o" "/LIBPATH:D:\\Users\\user\\projects\\cryptography\\src\\rust\\target\\release\\deps" "/LIBPATH:D:\\Users\\user\\projects\\cryptography\\src\\rust\\target\\release\\build\\cryptography-cffi-7b81ad29377686ed\\out" "/LIBPATH:D:\\Users\\user\\projects\\cryptography\\boringssl\\dist\\lib" "/LIBPATH:D:\\Users\\user\\projects\\cryptography\\src\\rust\\target\\release\\build\\openssl-sys-28d31fd83cf76cfe\\out" "/LIBPATH:D:\\Users\\user\\projects\\.pyenv\\pyenv-win\\versions\\3.10.11\\libs" "/LIBPATH:D:\\Program Files\\Rust\\rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib" "D:\\Users\\user\\projects\\cryptography\\src\\rust\\target\\release\\deps\\libcryptography_cffi-32eaafd4852ab88b.rlib" "D:\\Users\\user\\projects\\cryptography\\src\\rust\\target\\release\\deps\\libcryptography_keepalive-adfd755e24cb7727.rlib" "D:\\Users\\user\\projects\\cryptography\\src\\rust\\target\\release\\deps\\libcryptography_openssl-b82208269e3c23bc.rlib" "D:\\Users\\user\\projects\\cryptography\\src\\rust\\target\\release\\deps\\libpem-f93fb1130dd14926.rlib" "D:\\Users\\user\\projects\\cryptography\\src\\rust\\target\\release\\deps\\libbase64-197424feba3c1602.rlib" "D:\\Users\\user\\projects\\cryptography\\src\\rust\\target\\release\\deps\\libself_cell-d45923619a1ede24.rlib" "D:\\Users\\user\\projects\\cryptography\\src\\rust\\target\\release\\deps\\libcryptography_x509_verification-7b56f310aee922bf.rlib" "D:\\Users\\user\\projects\\cryptography\\src\\rust\\target\\release\\deps\\libcryptography_key_parsing-e8e715c7b97bb7bb.rlib" "D:\\Users\\user\\projects\\cryptography\\src\\rust\\target\\release\\deps\\libopenssl-35e25c6d766518e8.rlib" "D:\\Users\\user\\projects\\cryptography\\src\\rust\\target\\release\\deps\\libbitflags-3b88cc3e409eafae.rlib" "D:\\Users\\user\\projects\\cryptography\\src\\rust\\target\\release\\deps\\libforeign_types-9dd8838f73197a5f.rlib" "D:\\Users\\user\\projects\\cryptography\\src\\rust\\target\\release\\deps\\libforeign_types_shared-648d9a96cf26aff5.rlib" "D:\\Users\\user\\projects\\cryptography\\src\\rust\\target\\release\\deps\\libopenssl_sys-7af10b12a2367eb4.rlib" "D:\\Users\\user\\projects\\cryptography\\src\\rust\\target\\release\\deps\\libpyo3-273e41a0187c002f.rlib" "D:\\Users\\user\\projects\\cryptography\\src\\rust\\target\\release\\deps\\libcfg_if-3bae068768a8faee.rlib" "D:\\Users\\user\\projects\\cryptography\\src\\rust\\target\\release\\deps\\libmemoffset-1d9b3f5a801b86b7.rlib" "D:\\Users\\user\\projects\\cryptography\\src\\rust\\target\\release\\deps\\libonce_cell-6b4f5c1536ac6fa5.rlib" "D:\\Users\\user\\projects\\cryptography\\src\\rust\\target\\release\\deps\\libpyo3_ffi-c5aa673690f5c5c4.rlib" "D:\\Users\\user\\projects\\cryptography\\src\\rust\\target\\release\\deps\\liblibc-96f3ec3f0edb0ecc.rlib" "D:\\Users\\user\\projects\\cryptography\\src\\rust\\target\\release\\deps\\libunindent-4c88673c773ca8ea.rlib" "D:\\Users\\user\\projects\\cryptography\\src\\rust\\target\\release\\deps\\libcryptography_x509-56aac5d492683503.rlib" "D:\\Users\\user\\projects\\cryptography\\src\\rust\\target\\release\\deps\\libasn1-60aa3a470840bb9b.rlib" "D:\\Program Files\\Rust\\rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\libstd-287abad1c0bdb9b8.rlib" "D:\\Program Files\\Rust\\rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\libpanic_unwind-070c3734740ed997.rlib" "D:\\Program Files\\Rust\\rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\librustc_demangle-66a2a6c345ea9966.rlib" "D:\\Program Files\\Rust\\rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\libstd_detect-33c6cc56f7d1acea.rlib" "D:\\Program Files\\Rust\\rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\libhashbrown-f19d11c8f87bcdbf.rlib" "D:\\Program Files\\Rust\\rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\librustc_std_workspace_alloc-3928c78544f9c50c.rlib" "D:\\Program Files\\Rust\\rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\libunwind-8e773ac5f89895a1.rlib" "D:\\Program Files\\Rust\\rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\libcfg_if-fe105a06c709339c.rlib" "D:\\Program Files\\Rust\\rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\liblibc-a43d961d9021468a.rlib" "D:\\Program Files\\Rust\\rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\liballoc-d495230ba17bce41.rlib" "D:\\Program Files\\Rust\\rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\librustc_std_workspace_core-608b311ffd8bf0dd.rlib" "D:\\Program Files\\Rust\\rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\libcore-63e11cc35aa38f19.rlib" "D:\\Program Files\\Rust\\rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\libcompiler_builtins-9dbc16e13c04d841.rlib" "stdc++.lib" "gdi32.lib" "user32.lib" "crypt32.lib" "ws2_32.lib" "advapi32.lib" "python3.lib" "legacy_stdio_definitions.lib" "kernel32.lib" "advapi32.lib" "bcrypt.lib" "kernel32.lib" "ntdll.lib" "userenv.lib" "ws2_32.lib" "kernel32.lib" "ws2_32.lib" "kernel32.lib" "msvcrt.lib" "/NXCOMPAT" "/LIBPATH:D:\\Program Files\\Rust\\rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib" "/OUT:D:\\Users\\user\\projects\\cryptography\\src\\rust\\target\\release\\deps\\cryptography_rust.dll" "/OPT:REF,ICF" "/DLL" "/IMPLIB:D:\\Users\\user\\projects\\cryptography\\src\\rust\\target\\release\\deps\\cryptography_rust.dll.lib" "/DEBUG" "/NATVIS:D:\\Program Files\\Rust\\rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\etc\\intrinsic.natvis" "/NATVIS:D:\\Program Files\\Rust\\rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\etc\\liballoc.natvis" "/NATVIS:D:\\Program Files\\Rust\\rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\etc\\libcore.natvis" "/NATVIS:D:\\Program Files\\Rust\\rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\etc\\libstd.natvis"
  = note: LINK : fatal error LNK1181: cannot open input file 'stdc++.lib'


The following warnings were emitted during compilation:

warning: cargo:rustc-check-cfg requires -Zcheck-cfg=output flag
warning: cargo:rustc-check-cfg requires -Zcheck-cfg=output flag
warning: cargo:rustc-check-cfg requires -Zcheck-cfg=output flag
warning: cargo:rustc-check-cfg requires -Zcheck-cfg=output flag
warning: cargo:rustc-check-cfg requires -Zcheck-cfg=output flag

error: could not compile `cryptography-rust` (lib) due to previous error
💥 maturin failed
  Caused by: Failed to build a native library through cargo
  Caused by: Cargo build finished with "exit code: 101": `"cargo" "rustc" "--features" "pyo3/abi3-py37" "--message-format" "json-render-diagnostics" "--locked" "--manifest-path" "D:\\Users\\user\\projects\\cryptography\\src\\rust\\Cargo.toml" "--release" "--lib"`
Error: command ['maturin', 'pep517', 'build-wheel', '-i', 'D:\\Users\\user\\projects\\cryptography\\.venv\\Scripts\\python.exe', '--compatibility', 'off'] returned non-zero exit status 1

ERROR Backend subprocess exited when trying to invoke build_wheel

looks like the linker cannot find stdc++.lib.

@alex
Copy link
Member

alex commented Sep 14, 2024

What OpenSSL are you attempting to use?

@alex alex added the waiting-on-reporter Issue is waiting on a reply from the reporter. It will be automatically cloesd if there is no reply. label Sep 14, 2024
@HMaker
Copy link
Author

HMaker commented Sep 14, 2024

I am linking against BoringSSL from commit hash e724ef02089bf2bb494203231fc5cb62acc2fad6, same as the one used by cryptography in its tests.

@alex alex linked a pull request Sep 14, 2024 that will close this issue
@alex
Copy link
Member

alex commented Sep 14, 2024

#11603 should fix this, can you test and confirm?

@HMaker
Copy link
Author

HMaker commented Sep 14, 2024

@alex yes it builds now, I think the issue was linking stdc++ in Windows when using the MSVC compiler.

@alex
Copy link
Member

alex commented Sep 14, 2024

Great

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
waiting-on-reporter Issue is waiting on a reply from the reporter. It will be automatically cloesd if there is no reply.
Development

Successfully merging a pull request may close this issue.

2 participants