Linking with `link.exe` failed: exit code: 1181

Hello, I have a problem compiling a project with crate "k_board"

error: linking with link.exe failed: exit code: 1181
|
= note: "C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Tools\MSVC\14.43.34808\bin\HostX64\x64\link.exe" "/NOLOGO" "C:\Users\EOS\AppData\Local
\Temp\rustc0Fz3kT\symbols.o" "D:\snake\target\debug\deps\snake.2glfw72vqxle89ohura89vgie.rcgu.o" "D:\snake\target\debug\deps\snake.6l2xsu47980ly5ex3ehmbue3u.rcgu.o" "
D:\snake\target\debug\deps\snake.7a874ogd0kgz6ar4yincgfugf.rcgu.o" "D:\snake\target\debug\deps\snake.aj2uc0b27bw0xvv1go1z5i7w3.rcgu.o" "D:\snake\target\debug\deps\s
nake.bhr0oknjpclonvh91m852r9gl.rcgu.o" "D:\snake\target\debug\deps\snake.f2dstuh9ddxz31t8c531lkm7d.rcgu.o" "D:\snake\target\debug\deps\snake.1nwzbnhcss8tu0x46sntj0qfr.rc
gu.o" "D:\snake\target\debug\deps\libk_board-a4c00e5cb36ac889.rlib" "D:\snake\target\debug\deps\libcrossterm-492d91c21e279627.rlib" "D:\snake\target\debug\deps\libb
itflags-b1dff83d5416c954.rlib" "D:\snake\target\debug\deps\libparking_lot-a3beff5184fb1bad.rlib" "D:\snake\target\debug\deps\libparking_lot_core-fdb9416205257905.rlib" "
D:\snake\target\debug\deps\libsmallvec-e4511c186ea85b4d.rlib" "D:\snake\target\debug\deps\liblock_api-7d1f9f47ea0e2e60.rlib" "D:\snake\target\debug\deps\libscopegua
rd-6246bf6d4cf8d4bc.rlib" "D:\snake\target\debug\deps\libcrossterm_winapi-bdbebca45f32e032.rlib" "D:\snake\target\debug\deps\libwinapi-8414be612358201d.rlib" "D:\snake
\target\debug\deps\librand-e4aa94200fd00779.rlib" "D:\snake\target\debug\deps\librand_chacha-1ac8011bd8de6464.rlib" "D:\snake\target\debug\deps\libppv_lite86-642dff49
f6a78dec.rlib" "D:\snake\target\debug\deps\libzerocopy-b982d3662560b26f.rlib" "D:\snake\target\debug\deps\libbyteorder-9dd149fd95386a1e.rlib" "D:\snake\target\debug\
deps\librand_core-3a2d772dff885a0e.rlib" "D:\snake\target\debug\deps\libgetrandom-a69024983936c581.rlib" "D:\snake\target\debug\deps\libwindows_targets-3175f8b73061dfa0
.rlib" "D:\snake\target\debug\deps\libcfg_if-1a9bccb820b127e3.rlib" "D:\snake\target\debug\deps\libzerocopy-ce1ddf23c489af2b.rlib" "D:\snake\target\debug\deps\libla
zy_static-3dec4659ffbfa8a2.rlib" "C:\Users\EOS\.rustup\toolchains\stable-x86_64-pc-windows-msvc\lib\rustlib\x86_64-pc-windows-msvc\lib\libstd-e874d2af854a1269.rlib" "C:
\Users\EOS\.rustup\toolchains\stable-x86_64-pc-windows-msvc\lib\rustlib\x86_64-pc-windows-msvc\lib\libpanic_unwind-37750157ed47e215.rlib" "C:\Users\EOS\.rustup\toolch
ains\stable-x86_64-pc-windows-msvc\lib\rustlib\x86_64-pc-windows-msvc\lib\libwindows_targets-7e6fdb6e54c1cbdc.rlib" "C:\Users\EOS\.rustup\toolchains\stable-x86_64-pc-wi
ndows-msvc\lib\rustlib\x86_64-pc-windows-msvc\lib\librustc_demangle-cd9390cbc5edb100.rlib" "C:\Users\EOS\.rustup\toolchains\stable-x86_64-pc-windows-msvc\lib\rustlib\
x86_64-pc-windows-msvc\lib\libstd_detect-dff6af350245e14e.rlib" "C:\Users\EOS\.rustup\toolchains\stable-x86_64-pc-windows-msvc\lib\rustlib\x86_64-pc-windows-msvc\lib\l
ibhashbrown-941aa78eb62d6991.rlib" "C:\Users\EOS\.rustup\toolchains\stable-x86_64-pc-windows-msvc\lib\rustlib\x86_64-pc-windows-msvc\lib\librustc_std_workspace_alloc-2cc
5ffc24865e22c.rlib" "C:\Users\EOS\.rustup\toolchains\stable-x86_64-pc-windows-msvc\lib\rustlib\x86_64-pc-windows-msvc\lib\libunwind-be7fc3551dfe972e.rlib" "C:\Users\EO
S\.rustup\toolchains\stable-x86_64-pc-windows-msvc\lib\rustlib\x86_64-pc-windows-msvc\lib\libcfg_if-a64673ac839c7aad.rlib" "C:\Users\EOS\.rustup\toolchains\stable-x86
_64-pc-windows-msvc\lib\rustlib\x86_64-pc-windows-msvc\lib\liballoc-25a1d317141d196e.rlib" "C:\Users\EOS\.rustup\toolchains\stable-x86_64-pc-windows-msvc\lib\rustlib\
x86_64-pc-windows-msvc\lib\librustc_std_workspace_core-41d63ab94baafa04.rlib" "C:\Users\EOS\.rustup\toolchains\stable-x86_64-pc-windows-msvc\lib\rustlib\x86_64-pc-window
s-msvc\lib\libcore-b553d9e1000b8b90.rlib" "C:\Users\EOS\.rustup\toolchains\stable-x86_64-pc-windows-msvc\lib\rustlib\x86_64-pc-windows-msvc\lib\libcompiler_builtins-a1
285e9d3fe56144.rlib" "c.lib" "C:\Users\EOS\.cargo\registry\src\index.crates.io-6f17d22bba15001f\windows_x86_64_msvc-0.52.6\lib\windows.0.52.0.lib" "advapi32.lib" "cfgmgr3
2.lib" "gdi32.lib" "kernel32.lib" "msimg32.lib" "opengl32.lib" "synchronization.lib" "user32.lib" "winspool.lib" "C:\Users\EOS\.cargo\registry\src\index.crates.io-6f17d22bba
15001f\windows_x86_64_msvc-0.52.6\lib\windows.0.52.0.lib" "kernel32.lib" "kernel32.lib" "advapi32.lib" "ntdll.lib" "userenv.lib" "ws2_32.lib" "dbghelp.lib" "/defaultlib:msvcrt"
"/NXCOMPAT" "/LIBPATH:C:\Users\EOS\.cargo\registry\src\index.crates.io-6f17d22bba15001f\windows_x86_64_msvc-0.52.6\lib" "/OUT:D:\snake\target\debug\deps\snake.exe" "
/OPT:REF,NOICF" "/DEBUG" "/PDBALTPATH:%_PDB%" "/NATVIS:C:\Users\EOS\.rustup\toolchains\stable-x86_64-pc-windows-msvc\lib\rustlib\etc\intrinsic.natvis" "/NATVIS:C:\Users
\EOS\.rustup\toolchains\stable-x86_64-pc-windows-msvc\lib\rustlib\etc\liballoc.natvis" "/NATVIS:C:\Users\EOS\.rustup\toolchains\stable-x86_64-pc-windows-msvc\lib\rustlib\etc\libcore.natvis" "/NATVIS:C:\Users\EOS\.rustup\toolchains\stable-x86_64-pc-windows-msvc\lib\rustlib\etc\libstd.natvis"
= note: LINK : fatal error LNK1181: cannot open input file 'c.lib'␍

warning: snake (bin "snake") generated 13 warnings
error: could not compile snake (bin "snake") due to 1 previous error; 13 warnings emitted

Caused by:
process didn't exit successfully: C:\Users\EOS\.rustup\toolchains\stable-x86_64-pc-windows-msvc\bin\rustc.exe --crate-name snake --edition=2021 src\main.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts,future-incompat --diagnostic-width=178 --crate-type bin --emit=dep-info,link -C embed-bitcode=no -C debuginfo=2 --check-cfg cfg(docsrs) - -check-cfg "cfg(feature, values())" -C metadata=21d7d96664214fcd --out-dir D:\snake\target\debug\deps -C incremental=D:\snake\target\debug\incremental -L dependency=D:\snake\targe t\debug\deps --extern crossterm=D:\snake\target\debug\deps\libcrossterm-492d91c21e279627.rlib --extern k_board=D:\snake\target\debug\deps\libk_board-a4c00e5cb36ac889.rlib --extern lazy_static=D:\snake\target\debug\deps\liblazy_static-3dec4659ffbfa8a2.rlib --extern rand=D:\snake\target\debug\deps\librand-e4aa94200fd00779.rlib -L native=C:\Users\EOS\.cargo\registry\src\index.crates.io-6f17d22bba15001f\windows_x86_64_msvc-0.52.6\lib (exit code: 1)

"Windows 11 SDK (10.0.22621.0)" needs to be selected under "Optional". See: MSVC prerequisites - The rustup book

You have a newer version installed. I would expect it to work with either, but maybe the older version is explicitly required.

I installed the latest Windows 11 SDK

#[link(name = "c")]
extern "C" {
    /// `tcsetattr()` sets the parameters associated with the terminal
    /// (unless support is required from the underlying hardware that is
    /// not available) from the termios structure referred to by termios_p.
    /// optional_actions specifies when the changes take effect
    pub fn tcsetattr(fd: c_int, optional_actions: c_int, termios_p: *const termios) -> c_int;

I don't think k_board will work with windows. These functions are part of the termios api which is part of posix.

Also see this issue:

1 Like

I want to find a library where I can handle keystrokes like w a s d and arrow (left, right, up, down)

Depends on your application type. For tui/gui/game apps, these are usually provided by the tui/gui/game library you’ll use. Otherwise there are crates like rdev and device_query which appear to be crossplatform and might cover your needs.

1 Like

it is explicitly looking for a library named c, which is libc.a on posix systems, and c.lib on msvc. apparently, this will not work under msvc, because there's no libc. besides, even if you change libc to the msvc runtime (e.g. ucrt), it still won't work, because the API tcsetattr() is posix specific, it is not available on Windows.