106.07.19 rust error: linking with `link.exe` failed: exit code: 1

錯誤訊息:

error: linking with `link.exe` failed: exit code: 1
  |
  = note: "link.exe" "/NOLOGO" "/NXCOMPAT" "/LIBPATH:C:\\Users\\user\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib" "hello.0.o" "/OUT:hello.exe" "/OPT:REF,NOICF" "/DEBUG" "/LIBPATH:C:\\Users\\user\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib" "C:\\Users\\user\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\libstd-0a78323911070f99.rlib" "C:\\Users\\user\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\librand-c279a51d66700350.rlib" "C:\\Users\\user\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\libcollections-d7bf31a4ca1ea637.rlib" "C:\\Users\\user\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\libstd_unicode-d367c3ba0db49600.rlib" "C:\\Users\\user\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\libpanic_unwind-2d4bf02140c11dcb.rlib" "C:\\Users\\user\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\libunwind-add7a84d7e82d084.rlib" "C:\\Users\\user\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\liblibc-84688accbc86d6b7.rlib" "C:\\Users\\user\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\liballoc-fe2e68b21f0bdd7a.rlib" "C:\\Users\\user\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\liballoc_system-7fc0381594c93f56.rlib" "C:\\Users\\user\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\libcore-ea9d77e7c23fe65c.rlib" "C:\\Users\\user\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\libcompiler_builtins-91b619d34dd1f5aa.rlib" "advapi32.lib" "ws2_32.lib" "userenv.lib" "shell32.lib" "msvcrt.lib"
  = note: /usr/bin/link: 出現多餘的參數 ‘/LIBPATH:C:\\Users\\user\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib’
          Try '/usr/bin/link --help' for more information.


error: aborting due to previous error

直接執行 rustc 是沒問題的
上面那一大坨是在編譯時才出現
也就是 rustc hello.rs

發現我的link.exe是Cygwin裡面的
可從 觀看
link --help
裡面有提到GNU....

rust預設是安裝x86_64-pc-windows-msvc
然後發現測試通過的平台支援有x86_64-pc-windows-gnu
所以就不考慮使用MSVC了
把 .rustup 刪除後重新執行 rustup-init.exe 就成功了
記得要自訂安裝然後裝x86_64-pc-windows-gnu就對

2

x86_64-pc-windows-gnu (若是32bits可用 i686-pc-windows-gnu
這樣就可以編譯執行囉OuO



參考資料:
【已解决】link.exe 报错改如何解决?
Install Rust
Linking error with MSVC build #29479
error: linking with `link.exe` failed: exit code: 3221225781 #42744
So, how do I use MSVC in Rust Beta 1.2?

2 則留言:

^ Top