Cargo: windows: note: /usr/bin/link: extra operand

Created on 12 Feb 2017  路  5Comments  路  Source: rust-lang/cargo

It seems like https://github.com/rust-lang/cargo/issues/2242 is (partially) back or at least shows the same symptoms.

I had 1.12 installed via the Installer on Windows 7, just upgraded to 1.15.1 (via rustup, it prompted me to install the Visual C++ Redistributable and I complied)

# preparation for repro
git clone https://github.com/winks/cerith
cd cerith
git checkout 27ca5f67f7880fc5806e7862413a9d1651562834

# I originally had 1.15.1, but downgraded, error output is the same, sans path names
# cargo 0.15.0-nightly (298a012 2016-12-20)
# rustc 1.14.0 (e8a012324 2016-12-16)

cargo build
   Compiling regex-syntax v0.3.3
   Compiling utf8-ranges v0.1.3
   Compiling winapi v0.2.7
   Compiling winapi-build v0.1.1
   Compiling kernel32-sys v0.2.2
error: linking with `link.exe` failed: exit code: 1
  |
  = note: "link.exe" "/NOLOGO" "/NXCOMPAT" "/LIBPATH:C:\\Users\\Florian\\.rustup\\toolchains\\1.14.0-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib" "C:\\Users\\Florian\\code\\winks\\cerith\\target\\debug\\build\\kernel32-sys-d6afa5bd3d7cfaef\\build_script_build.0.o" "/OUT:C:\\Users\\Florian\\code\\winks\\cerith\\target\\debug\\build\\kernel32-sys-d6afa5bd3d7cfaef\\build_script_build.exe" "/OPT:REF,ICF" "/DEBUG" "/LIBPATH:C:\\Users\\Florian\\code\\winks\\cerith\\target\\debug\\deps" "/LIBPATH:C:\\Users\\Florian\\.rustup\\toolchains\\1.14.0-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib" "C:\\Users\\Florian\\code\\winks\\cerith\\target\\debug\\deps\\libbuild-493a7b0628804707.rlib" "C:\\Users\\Florian\\.rustup\\toolchains\\1.14.0-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\libstd-f5a209a9.rlib" "C:\\Users\\Florian\\.rustup\\toolchains\\1.14.0-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\libpanic_unwind-f5a209a9.rlib" "C:\\Users\\Florian\\.rustup\\toolchains\\1.14.0-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\libunwind-f5a209a9.rlib" "C:\\Users\\Florian\\.rustup\\toolchains\\1.14.0-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\librand-f5a209a9.rlib" "C:\\Users\\Florian\\.rustup\\toolchains\\1.14.0-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\libcollections-f5a209a9.rlib" "C:\\Users\\Florian\\.rustup\\toolchains\\1.14.0-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\librustc_unicode-f5a209a9.rlib" "C:\\Users\\Florian\\.rustup\\toolchains\\1.14.0-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\liblibc-f5a209a9.rlib" "C:\\Users\\Florian\\.rustup\\toolchains\\1.14.0-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\liballoc-f5a209a9.rlib" "C:\\Users\\Florian\\.rustup\\toolchains\\1.14.0-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\liballoc_system-f5a209a9.rlib" "C:\\Users\\Florian\\.rustup\\toolchains\\1.14.0-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\libcore-f5a209a9.rlib" "C:\\Users\\Florian\\.rustup\\toolchains\\1.14.0-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\libcompiler_builtins-f5a209a9.rlib" "ws2_32.lib" "userenv.lib" "shell32.lib" "advapi32.lib" "msvcrt.lib"
  = note: /usr/bin/link: extra operand '/LIBPATH:C:\\Users\\Florian\\.rustup\\toolchains\\1.14.0-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib'
Try '/usr/bin/link --help' for more information.

Most helpful comment

MinGW/Cygwin link.exe is run instead of MSBC link.exe. Placing MinGW/Cygwin after MSVC dirs will solve the issue.

All 5 comments

OK, reinstalling and rebooting fixed it. Didn't look like a PATH issue, maybe it was. Sorry for the noise.

MinGW/Cygwin link.exe is run instead of MSBC link.exe. Placing MinGW/Cygwin after MSVC dirs will solve the issue.

While this may apply for some people, I don't have (and didn't have) Cygwin installed on this machine.

user PATH: C:\Users\Florian\.cargo\bin;;C:\Program Files (x86)\Microsoft VS Code\bin

 sys PATH: C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\Intel\OpenCL SDK\2.0\bin\x86;C:\Program Files (x86)\Intel\OpenCL SDK\2.0\bin\x64;C:\Program Files (x86)\GNU\GnuPG\pub;C:\ProgramData\chocolatey\bin;C:\Program Files (x86)\Common Files\Adobe\AGL;C:\Program Files (x86)\Windows Kits\8.1\Windows Performance Toolkit\;C:\Apps\misc\Go\bin;C:\Program Files\Java\jdk1.8.0_144\bin;
Microsoft Windows [Version 10.0.18362.535]
(c) 2019 Microsoft Corporation. All rights reserved.

C:\Users\info>where link
C:\Program Files\Git\usr\bin\link.exe
C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\VC\Tools\MSVC\14.16.27023\bin\Hostx64\x64\link.exe

C:\Users\info>which link
/usr/bin/link

C:\Users\info>

Here, Git's link was being used.

I had C:\Program Files\Git\usr\bin added on the System's PATH and C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\VC\Tools\MSVC\14.16.27023\bin\Hostx64\x64 on my User PATH.

In case anyone has this issue and there's no issue with PATH/rebooting does not fix it for them, reinstalling the Visual Studio build tools fixed it for me.

Was this page helpful?
0 / 5 - 0 ratings