First program, first error


This is my first time running Rust with hello world and I have below error when compile.
I am using Cygwin on Windows. Rust version 1.20.0
Is there anything wrong with my PATH?
Please advice me.


$ rustc
error: linking with `link.exe` failed: exit code: 1
  = note: "link.exe" "/NOLOGO" "/NXCOMPAT" "/LIBPATH:C:\\Users\\Thang\\.rustup\                              \toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msv                              c\\lib" "main.0.o" "/OUT:main.exe" "main.crate.allocator.o" "/OPT:REF,NOICF" "/                              DEBUG" "/LIBPATH:C:\\Users\\Thang\\.rustup\\toolchains\\stable-x86_64-pc-window                              s-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib" "C:\\Users\\Thang\\.rustup\\                              toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc                              \\lib\\libstd-dd7c96bff832962e.rlib" "C:\\Users\\Thang\\.rustup\\toolchains\\st                              able-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\liballo                              c_system-c0ca30c8d8f2ee24.rlib" "C:\\Users\\Thang\\.rustup\\toolchains\\stable-                              x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\librand-a299                              d02141336ab8.rlib" "C:\\Users\\Thang\\.rustup\\toolchains\\stable-x86_64-pc-win                              dows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\libpanic_unwind-5fee39473                              6e5c5eb.rlib" "C:\\Users\\Thang\\.rustup\\toolchains\\stable-x86_64-pc-windows-                              msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\liblibc-d67437f4f22ef3c2.rlib"                               "C:\\Users\\Thang\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\ru                              stlib\\x86_64-pc-windows-msvc\\lib\\liballoc-db87982aeb7cd775.rlib" "C:\\Users\                              \Thang\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_6                              4-pc-windows-msvc\\lib\\libstd_unicode-9ffbffc259cf112a.rlib" "C:\\Users\\Thang                              \\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-w                              indows-msvc\\lib\\libunwind-9027c96a793ab959.rlib" "C:\\Users\\Thang\\.rustup\\                              toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc                              \\lib\\libcore-e56c10976581c51e.rlib" "C:\\Users\\Thang\\.rustup\\toolchains\\s                              table-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\libcom                              piler_builtins-4f8e9eb49e791bd8.rlib" "advapi32.lib" "ws2_32.lib" "userenv.lib"                               "shell32.lib" "msvcrt.lib"
  = note: link: extra operand ‘/LIBPATH:C:\\Users\\Thang\\.rustup\\toolchains\\                              stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib’
          Try 'link --help' for more information.

error: aborting due to previous error


Would you be able to wrap that error message in code tags to make it easier to read? Usually linker errors are laid out so you have the original command which was executed, then a newline, then something explaining what went wrong. Without formatting everything gets merged together and it’s hard to find the explanation from rustc.

You’d write something like this:

$ rustc
(rest of error message here)

I’d suggest running rustc with the --verbose flag and seeing if that gives you a more useful error message. At the moment rustc is just saying it failed to perform the linking step and is showing you the command which was run.

I think the relevant bit is:

note: link: extra operand ‘/LIBPATH:C:\Users\Thang.rustup\toolchains\ stable-x86_64-pc-windows-msvc\lib\rustlib\x86_64-pc-windows-msvc\lib’

It sounds like rustc is passing the /LIBPATH flag to the microsoft linker and the linker doesn’t accept any unknown arguments. Someone who knows more about Windows or how rustc uses the linker may know more though…


Hi @thangnguyen!

You said:

But your output says

Note the “link.exe” and “stable-x86_64-pc-windows-msvc” in there. This means you’re trying to build with MSVC Rust, not minGW. Is that what you wanted?


You means I use a wrong package correct?
I really don’t have preference right now. I want to learn rust.
I downloaded rustup-init.exe from
then I have just start reading the book Look like I should install rust from my Cygwin instead of install from .exe file.



It’s only wrong if you don’t want to use the MSVC version; that’s the version most people use on Windows. To use it, you have to follow the additional instructions here

That said, it should work fine with Cygwin too, you just need the right package.