rust-lang / rust

Empowering everyone to build reliable and efficient software.
https://www.rust-lang.org
Other
97.5k stars 12.61k forks source link

linking with `x86_64-w64-mingw32-gcc` failed: exit code: 1 #118005

Open KartikeyBartwal opened 10 months ago

KartikeyBartwal commented 10 months ago

Not even building a fresh project. Yes VS desktop C++ has been installed and been added to path variables. Also mingw64 has been installed and that too has been added to the path variable

Error:

error: linking with x86_64-w64-mingw32-gcc failed: exit code: 1 | = note: "x86_64-w64-mingw32-gcc" "-fno-use-linker-plugin" "-Wl,--dynamicbase" "-Wl,--disable-auto-image-base" "-m64" "-Wl,--high-entropy-va" "C:\Users\hp\.rustup\toolchains\stable-x86_64-pc-windows-gnu\lib\rustlib\x86_64-pc-windows-gnu\lib\rsbegin.o" "C:\Users\hp\AppData\Local\Temp\rustcWPFgKu\symbols.o" "F:\Freelancing\rusty\myproject\target\debug\deps\myproject-f6ee3bfcbfc82562.1f3io9pxne13u7no.rcgu.o" "F:\Freelancing\rusty\myproject\target\debug\deps\myproject-f6ee3bfcbfc82562.1o4dgej4c5o89ifr.rcgu.o" "F:\Freelancing\rusty\myproject\target\debug\deps\myproject-f6ee3bfcbfc82562.1qb09i8zvnqv1rh4.rcgu.o" "F:\Freelancing\rusty\myproject\target\debug\deps\myproject-f6ee3bfcbfc82562.2kj4hp7tttd39ja9.rcgu.o" "F:\Freelancing\rusty\myproject\target\debug\deps\myproject-f6ee3bfcbfc82562.48dqogwwp4p84p8z.rcgu.o" "F:\Freelancing\rusty\myproject\target\debug\deps\myproject-f6ee3bfcbfc82562.s92gw3kgy9sxvug.rcgu.o" "F:\Freelancing\rusty\myproject\target\debug\deps\myproject-f6ee3bfcbfc82562.1ewwxbq2q6owd5gm.rcgu.o" "-L" "F:\Freelancing\rusty\myproject\target\debug\deps" "-L" "C:\Users\hp\.rustup\toolchains\stable-x86_64-pc-windows-gnu\lib\rustlib\x86_64-pc-windows-gnu\lib" "-Wl,-Bstatic" "C:\Users\hp\.rustup\toolchains\stable-x86_64-pc-windows-gnu\lib\rustlib\x86_64-pc-windows-gnu\lib\libstd-02223d1a8ebc115e.rlib" "C:\Users\hp\.rustup\toolchains\stable-x86_64-pc-windows-gnu\lib\rustlib\x86_64-pc-windows-gnu\lib\libpanic_unwind-74c2a9f631b8e711.rlib" "C:\Users\hp\.rustup\toolchains\stable-x86_64-pc-windows-gnu\lib\rustlib\x86_64-pc-windows-gnu\lib\libobject-2b9017bcde11e9ca.rlib" "C:\Users\hp\.rustup\toolchains\stable-x86_64-pc-windows-gnu\lib\rustlib\x86_64-pc-windows-gnu\lib\libmemchr-772ada775d181d76.rlib" "C:\Users\hp\.rustup\toolchains\stable-x86_64-pc-windows-gnu\lib\rustlib\x86_64-pc-windows-gnu\lib\libaddr2line-3f96cda30c8cc4c2.rlib" "C:\Users\hp\.rustup\toolchains\stable-x86_64-pc-windows-gnu\lib\rustlib\x86_64-pc-windows-gnu\lib\libgimli-d0b4292462dd97e8.rlib" "C:\Users\hp\.rustup\toolchains\stable-x86_64-pc-windows-gnu\lib\rustlib\x86_64-pc-windows-gnu\lib\librustc_demangle-8a393c802342f4ef.rlib" "C:\Users\hp\.rustup\toolchains\stable-x86_64-pc-windows-gnu\lib\rustlib\x86_64-pc-windows-gnu\lib\libstd_detect-7d5af5f778f36d87.rlib" "C:\Users\hp\.rustup\toolchains\stable-x86_64-pc-windows-gnu\lib\rustlib\x86_64-pc-windows-gnu\lib\libhashbrown-499a000973452be0.rlib" "C:\Users\hp\.rustup\toolchains\stable-x86_64-pc-windows-gnu\lib\rustlib\x86_64-pc-windows-gnu\lib\librustc_std_workspace_alloc-59d9c96926e07b45.rlib" "C:\Users\hp\.rustup\toolchains\stable-x86_64-pc-windows-gnu\lib\rustlib\x86_64-pc-windows-gnu\lib\libminiz_oxide-8266c8b00a6b8484.rlib" "C:\Users\hp\.rustup\toolchains\stable-x86_64-pc-windows-gnu\lib\rustlib\x86_64-pc-windows-gnu\lib\libadler-993d789456995568.rlib" "C:\Users\hp\.rustup\toolchains\stable-x86_64-pc-windows-gnu\lib\rustlib\x86_64-pc-windows-gnu\lib\libunwind-cd8702b2c5580e5a.rlib" "C:\Users\hp\.rustup\toolchains\stable-x86_64-pc-windows-gnu\lib\rustlib\x86_64-pc-windows-gnu\lib\libcfg_if-5b532d82651f6971.rlib" "C:\Users\hp\.rustup\toolchains\stable-x86_64-pc-windows-gnu\lib\rustlib\x86_64-pc-windows-gnu\lib\liblibc-7b52c791f365dc75.rlib" "C:\Users\hp\.rustup\toolchains\stable-x86_64-pc-windows-gnu\lib\rustlib\x86_64-pc-windows-gnu\lib\liballoc-898fc0b73bfb6915.rlib" "C:\Users\hp\.rustup\toolchains\stable-x86_64-pc-windows-gnu\lib\rustlib\x86_64-pc-windows-gnu\lib\librustc_std_workspace_core-650bcbefd1e15e94.rlib" "C:\Users\hp\.rustup\toolchains\stable-x86_64-pc-windows-gnu\lib\rustlib\x86_64-pc-windows-gnu\lib\libcore-97a44e472671e5e8.rlib" "C:\Users\hp\.rustup\toolchains\stable-x86_64-pc-windows-gnu\lib\rustlib\x86_64-pc-windows-gnu\lib\libcompiler_builtins-678ac04ded51390b.rlib" "-Wl,-Bdynamic" "-lkernel32" "-ladvapi32" "-lbcrypt" "-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\hp\.rustup\toolchains\stable-x86_64-pc-windows-gnu\lib\rustlib\x86_64-pc-windows-gnu\lib" "-o" "F:\Freelancing\rusty\myproject\target\debug\deps\myproject-f6ee3bfcbfc82562.exe" "-Wl,--gc-sections" "-no-pie" "-nodefaultlibs" "C:\Users\hp\.rustup\toolchains\stable-x86_64-pc-windows-gnu\lib\rustlib\x86_64-pc-windows-gnu\lib\rsend.o" = note: Warning: .drectve -exclude-symbols:_ZN3std2rt10lang_start17h3713f2d2434f512cE ' unrecognized Warning: corrupt .drectve at end of def file Warning: corrupt .drectve at end of def file Warning: corrupt .drectve at end of def file Warning: .drectve-exclude-symbols:"_ZN4core3ops8function6FnOnce40call_once$u7b$$u7b$vtable.shim$u7d$$u7d$17h852531509b4e196aE" ' unrecognized Warning: .drectve -exclude-symbols:_ZN4core3ops8function6FnOnce9call_once17he6e86f0a96970fdbE ' unrecognized Warning: corrupt .drectve at end of def file Warning: corrupt .drectve at end of def file Warning: corrupt .drectve at end of def file Warning: corrupt .drectve at end of def file D:/Programming/Compilers/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: F:\Freelancing\rusty\myproject\target\debug\deps\myproject-f6ee3bfcbfc82562.48dqogwwp4p84p8z.rcgu.o: in functioncore::ops::function::FnOnce::call_once': /rustc/79e9716c980570bfd1f666e3b16ac583f0168962\library\core\src\ops/function.rs:250: undefined reference to _Unwind_Resume' D:/Programming/Compilers/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\Users\hp\.rustup\toolchains\stable-x86_64-pc-windows-gnu\lib\rustlib\x86_64-pc-windows-gnu\lib\libstd-02223d1a8ebc115e.rlib(std-02223d1a8ebc115e.std.af1a2b6936baa967-cgu.0.rcgu.o): in functionalloc::collections::btree::mem::replace': /rustc/79e9716c980570bfd1f666e3b16ac583f0168962/library\alloc\src\collections\btree/mem.rs:(.text+0x28f): undefined reference to _Unwind_Resume' D:/Programming/Compilers/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\Users\hp\.rustup\toolchains\stable-x86_64-pc-windows-gnu\lib\rustlib\x86_64-pc-windows-gnu\lib\libstd-02223d1a8ebc115e.rlib(std-02223d1a8ebc115e.std.af1a2b6936baa967-cgu.0.rcgu.o): in function::fmt': /rustc/79e9716c980570bfd1f666e3b16ac583f0168962/library\std\src/backtrace.rs:(.text+0xa81): undefined reference to _Unwind_Resume' D:/Programming/Compilers/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\Users\hp\.rustup\toolchains\stable-x86_64-pc-windows-gnu\lib\rustlib\x86_64-pc-windows-gnu\lib\libstd-02223d1a8ebc115e.rlib(std-02223d1a8ebc115e.std.af1a2b6936baa967-cgu.0.rcgu.o): in functioncore::ops::function::FnOnce::call_once': /rustc/79e9716c980570bfd1f666e3b16ac583f0168962/library\core\src\ops/function.rs:250: undefined reference to _Unwind_Resume' D:/Programming/Compilers/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\Users\hp\.rustup\toolchains\stable-x86_64-pc-windows-gnu\lib\rustlib\x86_64-pc-windows-gnu\lib\libstd-02223d1a8ebc115e.rlib(std-02223d1a8ebc115e.std.af1a2b6936baa967-cgu.0.rcgu.o): in functioncore::ops::function::FnOnce::call_once': /rustc/79e9716c980570bfd1f666e3b16ac583f0168962/library\core\src\ops/function.rs:(.text+0x1fc4): undefined reference to _Unwind_Resume' D:/Programming/Compilers/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\Users\hp\.rustup\toolchains\stable-x86_64-pc-windows-gnu\lib\rustlib\x86_64-pc-windows-gnu\lib\libstd-02223d1a8ebc115e.rlib(std-02223d1a8ebc115e.std.af1a2b6936baa967-cgu.0.rcgu.o):/rustc/79e9716c980570bfd1f666e3b16ac583f0168962/library\std\src\thread/mod.rs:(.text+0x21c2): more undefined references to_Unwind_Resume' follow D:/Programming/Compilers/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\Users\hp.rustup\toolchains\stable-x86_64-pc-windows-gnu\lib\rustlib\x86_64-pc-windows-gnu\lib\libstd-02223d1a8ebc115e.rlib(std-02223d1a8ebc115e.std.af1a2b6936baa967-cgu.0.rcgu.o):/rustc/79e9716c980570bfd1f666e3b16ac583f0168962/library\std\src\sys\personality/gcc.rs:248: undefined reference to _GCC_specific_handler' D:/Programming/Compilers/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\Users\hp\.rustup\toolchains\stable-x86_64-pc-windows-gnu\lib\rustlib\x86_64-pc-windows-gnu\lib\libstd-02223d1a8ebc115e.rlib(std-02223d1a8ebc115e.std.af1a2b6936baa967-cgu.0.rcgu.o): in function::next': /rustc/79e9716c980570bfd1f666e3b16ac583f0168962/library\std\src\sys\windows/fs.rs:796: undefined reference to _Unwind_Resume' D:/Programming/Compilers/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\Users\hp\.rustup\toolchains\stable-x86_64-pc-windows-gnu\lib\rustlib\x86_64-pc-windows-gnu\lib\libstd-02223d1a8ebc115e.rlib(std-02223d1a8ebc115e.std.af1a2b6936baa967-cgu.0.rcgu.o): in function::fmt': /rustc/79e9716c980570bfd1f666e3b16ac583f0168962/library\std\src\sys\windows/fs.rs:913: undefined reference to _Unwind_Resume' D:/Programming/Compilers/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\Users\hp\.rustup\toolchains\stable-x86_64-pc-windows-gnu\lib\rustlib\x86_64-pc-windows-gnu\lib\libstd-02223d1a8ebc115e.rlib(std-02223d1a8ebc115e.std.af1a2b6936baa967-cgu.0.rcgu.o): in functionstd::sys::windows::fs::readdir': /rustc/79e9716c980570bfd1f666e3b16ac583f0168962/library\std\src\sys\windows/fs.rs:1084: undefined reference to _Unwind_Resume' D:/Programming/Compilers/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: /rustc/79e9716c980570bfd1f666e3b16ac583f0168962/library\std\src\sys\windows/fs.rs:1084: undefined reference to_Unwind_Resume' D:/Programming/Compilers/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\Users\hp.rustup\toolchains\stable-x86_64-pc-windows-gnu\lib\rustlib\x86_64-pc-windows-gnu\lib\libstd-02223d1a8ebc115e.rlib(std-02223d1a8ebc115e.std.af1a2b6936baa967-cgu.0.rcgu.o): in function std::sys::windows::fs::rename': /rustc/79e9716c980570bfd1f666e3b16ac583f0168962/library\std\src\sys\windows/fs.rs:1097: undefined reference to_Unwind_Resume' D:/Programming/Compilers/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\Users\hp.rustup\toolchains\stable-x86_64-pc-windows-gnu\lib\rustlib\x86_64-pc-windows-gnu\lib\libstd-02223d1a8ebc115e.rlib(std-02223d1a8ebc115e.std.af1a2b6936baa967-cgu.0.rcgu.o):/rustc/79e9716c980570bfd1f666e3b16ac583f0168962/library\std\src\sys\windows/fs.rs:1141: more undefined references to _Unwind_Resume' follow D:/Programming/Compilers/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\Users\hp\.rustup\toolchains\stable-x86_64-pc-windows-gnu\lib\rustlib\x86_64-pc-windows-gnu\lib\libpanic_unwind-74c2a9f631b8e711.rlib(panic_unwind-74c2a9f631b8e711.panic_unwind.8a44579ff4aaea68-cgu.0.rcgu.o): in functionpanic_unwind::real_imp::panic': /rustc/79e9716c980570bfd1f666e3b16ac583f0168962/library\panic_unwind\src/gcc.rs:72: undefined reference to _Unwind_RaiseException' D:/Programming/Compilers/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\Users\hp\.rustup\toolchains\stable-x86_64-pc-windows-gnu\lib\rustlib\x86_64-pc-windows-gnu\lib\libpanic_unwind-74c2a9f631b8e711.rlib(panic_unwind-74c2a9f631b8e711.panic_unwind.8a44579ff4aaea68-cgu.0.rcgu.o): in functionalloc::boxed::Box::new': /rustc/79e9716c980570bfd1f666e3b16ac583f0168962/library\alloc\src/boxed.rs:(.text+0x1fa): undefined reference to _Unwind_Resume' D:/Programming/Compilers/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\Users\hp\.rustup\toolchains\stable-x86_64-pc-windows-gnu\lib\rustlib\x86_64-pc-windows-gnu\lib\libobject-2b9017bcde11e9ca.rlib(object-2b9017bcde11e9ca.object.91cdb3ce93b1f77-cgu.0.rcgu.o):object.91cdb3ce93b:(.text+0x1d07): undefined reference to_Unwind_Resume' D:/Programming/Compilers/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\Users\hp.rustup\toolchains\stable-x86_64-pc-windows-gnu\lib\rustlib\x86_64-pc-windows-gnu\lib\libobject-2b9017bcde11e9ca.rlib(object-2b9017bcde11e9ca.object.91cdb3ce93b1f77-cgu.0.rcgu.o):object.91cdb3ce93b:(.text+0x3f64): undefined reference to _Unwind_Resume' D:/Programming/Compilers/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\Users\hp\.rustup\toolchains\stable-x86_64-pc-windows-gnu\lib\rustlib\x86_64-pc-windows-gnu\lib\libobject-2b9017bcde11e9ca.rlib(object-2b9017bcde11e9ca.object.91cdb3ce93b1f77-cgu.0.rcgu.o):object.91cdb3ce93b:(.text+0x5b57): undefined reference to_Unwind_Resume' D:/Programming/Compilers/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\Users\hp.rustup\toolchains\stable-x86_64-pc-windows-gnu\lib\rustlib\x86_64-pc-windows-gnu\lib\libobject-2b9017bcde11e9ca.rlib(object-2b9017bcde11e9ca.object.91cdb3ce93b1f77-cgu.0.rcgu.o):object.91cdb3ce93b:(.text+0x677a): undefined reference to _Unwind_Resume' D:/Programming/Compilers/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\Users\hp\.rustup\toolchains\stable-x86_64-pc-windows-gnu\lib\rustlib\x86_64-pc-windows-gnu\lib\libgimli-d0b4292462dd97e8.rlib(gimli-d0b4292462dd97e8.gimli.258e2be751a388c9-cgu.0.rcgu.o):gimli.258e2be751a3:(.text+0x85f): more undefined references to_Unwind_Resume' follow collect2.exe: error: ld returned 1 exit status

= note: some extern functions couldn't be found; some native libraries may need to be installed or have their path specified = note: use the -l flag to specify native libraries to link = note: use the cargo:rustc-link-lib directive to specify the native libraries to link with Cargo (see https://doc.rust-lang.org/cargo/reference/build-scripts.html#cargorustc-link-libkindname)

error: could not compile myproject (bin "myproject") due to previous error

.main:

fn main() {
    println!("Hello, world!");
}

cargo.toml:

[package]
name = "myproject"
version = "0.1.0"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
saethlin commented 10 months ago

Is this a duplicate of https://github.com/rust-lang/rust/issues/112368 ?

hsn10 commented 4 months ago

no

afifurrohman-id commented 4 months ago

Not even building a fresh project. Yes VS desktop C++ has been installed and been added to path variables. Also mingw64 has been installed and that too has been added to the path variable

I would be recommended you use WSL2 instead of native windows to development in rust. since wsl is support systemd, means you can install container engine like docker and vscode give you wsl extesion too, or you can use neovim. there should be no reason for development rust using native windows except you want to targeting windows platform.

I use wsl for daily development with rust and it's just works fine.

mati865 commented 4 months ago

Also mingw64 has been installed and that too has been added to the path variable

What toolchain precisely did you install? The error looks like you are using a toolchain with win32 threads.