When building a project using the x86_64-pc-windows-gnu toolchain, an error occurs:
PS E:\Daily\Desktop\hello> cargo build --target=x86_64-pc-windows-gnu
Compiling hello v0.1.0 (E:\Daily\Desktop\hello)
error: linking with `C:\msys64\mingw64\bin\gcc.exe` failed: exit code: 1
|
= note: "C:\msys64\mingw64\bin\gcc.exe" "-fno-use-linker-plugin" "-Wl,--dynamicbase" "-Wl,--disable-auto-image-base" "-m64" "-Wl,--high-entropy-va" "C:\Users\AXH69\.rustup\toolchains\stable-
x86_64-pc-windows-msvc\lib\rustlib\x86_64-pc-windows-gnu\lib\rsbegin.o" "C:\Users\AXH69\AppData\Local\Temp\rustcxzitGJ\symbols.o" "E:\Daily\Desktop\hello\target\x86_64-pc-windows-gnu\
debug\deps\hello-9bbe4c028840d372.19m6pwdq3w7fawf9.rcgu.o" "E:\Daily\Desktop\hello\target\x86_64-pc-windows-gnu\debug\deps\hello-9bbe4c028840d372.20vd8t7a6aaak3td.rcgu.o" "E:\Daily\Desktop
\hello\target\x86_64-pc-windows-gnu\debug\deps\hello-9bbe4c028840d372.21gunfaq851zmvk4.rcgu.o" "E:\Daily\Desktop\hello\target\x86_64-pc-windows-gnu\debug\deps\hello-9bbe4c028840d372.2rlp77
ph9mnpflrn.rcgu.o" "E:\Daily\Desktop\hello\target\x86_64-pc-windows-gnu\debug\deps\hello-9bbe4c028840d372.3iajtln59dr1976v.rcgu.o" "E:\Daily\Desktop\hello\target\x86_64-pc-windows-gnu\debug\deps\hello-9bbe4c028840d372.52yb8x5xhb7rk88m.rcgu.o" "-L" "E:\Daily\Desktop
\hello\target\x86_64-pc-windows-gnu\debug\deps" "-L" "E:\Daily\Desktop\hello\target\debug\deps" "-L" "C:\Users\AXH69\.rustup\toolchains\stable-x86_64-pc-windows-msvc\lib\rustlib\x86_
.rustup\toolchains\stable-x86_64-pc-windows-msvc\lib\rustlib\x86_64-pc-windows-gnu\lib\libpanic_unwind-17d59fcffbb1858c.rlib" "C:\Users\AXH69\.rustup\toolchains\stable-x86_64-pc-windows-msvc\lib\rustlib\x86_64-pc-windows-gnu\lib\libobject-bbbe10091d0fd58d.rlib" "C:\Users\AXH69\.rustup\toolchains\stable-x86_64-pc-windows-msvc\lib\rustlib\x86_64-pc-windows-gnu\lib\libmemchr-ff20eb48d2567174.rlib" "C:\Users\AXH69\.rustup\toolchains\stable-x86_64-pc-windows-msvc\lib\rustlib\x86_64-pc-windows-gnu\lib\libaddr2line-030e3ef637a6c0e1.rlib" "C:\Users\AXH69\.rustup\toolchains\stable-x86_64-pc-windows-msvc\lib\rustlib\x86_64-pc-windows-gnu\lib\libgimli-53e82cde34eb1119.rlib" "C:\Users\AXH69\.rustup\toolchains\stable-x86_64-pc-windows-msvc\lib\rustlib\x86_64-pc-windows-gnu\lib\librustc_demangle-8a1d947ff4a075c3.rlib" "C:\Users\AXH69\.rustup\toolchains\stable-x86_64-pc-windows-msvc\lib\rustlib\x86_64-pc-windows-gnu\lib\libstd_detect-a6a7bc9844ea0859.rlib" "C:\Users\AXH69\.rustup\toolchains\stable-x86_64-pc-windows-msvc\lib\rustlib\x86_64-pc-windows-gnu\lib\libhashbrown-a963c0ad0363ef1a.rlib" "C:\Users\AXH69\.rustup\toolchains\stable-x86_64-pc-windows-msvc\lib\rustlib\x86_64-pc-windows-gnu\lib\librustc_std_workspace_alloc-1bc86c6d4a47ec27.rlib" "C:\Users\AXH69\.rustup\toolchains\stable-x86_64-pc-windows-msvc\lib\rustlib\x86_64-pc-windows-gnu\lib\libminiz_oxide-57b7601d31d3fe19.rlib" "C:\Users\AXH69\.rustup\toolchains\stable-x86_64-pc-windows-msvc\lib\rustlib\x86_64-pc-windows-gnu\lib\libadler-5ea4baaad4eac651.rlib" "C:\Users\AXH69\.rustup\toolchains\stable-x86_64-pc-windows-msvc\lib\rustlib\x86_64-pc-windows-gnu\lib\libunwind-504a546f931d1b95.rlib" "C:\Users\AXH69\.rustup\toolchains\stable-x86_64-pc-windows-msvc\lib\rustlib\x86_64-pc-windows-gnu\lib\libcfg_if-c18dc5b831cc4c35.rlib" "C:\Users\AXH69\.rustup\toolchains\stable-x86_64-pc-windows-msvc\lib\rustlib\x86_64-pc-windows-gnu\lib\liblibc-3a48b664c1fa889c.rlib" "C:\Users\AXH69\.rustup\toolchains\stable-x86_64-pc-windows-msvc\lib\rustlib\x86_64-pc-windows-gnu\lib\liballoc-2552a9f38657c70e.rlib" "C:\Users\AXH69\.rustup\toolchains\stable-x86_64-pc-windows-msvc\lib\rustlib\x86_64-pc-windows-gnu\lib\librustc_std_workspace_core-dab1b9a2489b7d16.rlib" "C:\Users\AXH69\.rustup\toolchains\stable-x86_64-pc-windows-msvc\lib\rustlib\x86_64-pc-windows-gnu\lib\libcore-d7fd3f351d39ae46.rlib" "C:\Users\AXH69\.rustup\toolchains\stable-x86_64-pc-windows-msvc\lib\rustlib\x86_64-pc-windows-gnu\lib\libcompiler_builtins-b44a9797859024b2.rlib" "-Wl,-Bdynamic" "-lkernel32" "-ladvapi32" "-lkernel32" "-lntdll" "-luserenv" "-lws2_32" "-lkernel32" "- lws2_32" "-lkernel32" "-lgcc_eh" "-l:libpthread.a" "-lmsvcrt" "-lmingwex" "-lmingw32" "-lgcc" "-lmsvcrt" "-luser32" "-lkernel32" "-Wl,--nxcompat" "-L" "C:\Users\AXH69\.rustup\toolchains\stable-x86_64-pc-windows-msvc\lib\rustlib\x86_64-pc-windows-gnu\lib" "-o" "E:\Daily\Desktop\hello\target\x86_64-pc-windows-gnu\debug\deps\hello-9bbe4c028840d372.exe" "-Wl,--gc-sections" "-no-pie" "-nodefaultlibs" "C:\Users\AXH69\.rustup\toolchains\stable-x86_64-pc-windows-msvc\lib\rustlib\x86_64-pc-windows-gnu\lib\rsend.o"
= note:
error: could not compile `hello` (bin "hello") due to 1 previous error
The above is the complete content of the console error report.
//main.rs
fn main() {
println!("Hello, world!");
}
//cargo.toml
[package]
name = "hello"
version = "0.1.0"
edition = "2021"
[dependencies]
//.cargo/config.toml
[target.i686-pc-windows-msvc]
rustflags = ["-C", "target-feature=+crt-static"]
linker = "C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Tools\MSVC\14.39.33519\bin\Hostx86\x86\link.exe"
[target.i686-pc-windows-gnu]
linker = "C:\DevKit\MinGW\bin\gcc.exe"
ar = "C:\DevKit\MinGW\bin\ar.exe"
[target.x86_64-pc-windows-gnu]
linker = "C:\msys64\mingw64\bin\gcc.exe"
ar = "C:\msys64\mingw64\bin\ar.exe"
I want to know why this error occurred? I couldn't find relevant information online, and I can build and run normally using x86_64-pc-windows-msvc