Home > OS >  Windows 10 error: linking with `x86_64-w64-mingw32-gcc` failed: exit code: 1
Windows 10 error: linking with `x86_64-w64-mingw32-gcc` failed: exit code: 1

Time:05-15

I am struggling to fix error: linking with 'x86_64-w64-mingw32-gcc; failed: exit code: 1, I have installed TDM-GCC-64 and Cygwin and added them to PATH as well as updating the c 2019 redistributable. I am attempting to use GLFW or an alternative but when ever I try I to run the rust projects that use GLFW or its alternatives I get this error note: C:/TDM-GCC-64/bin/../lib/gcc/x86_64-w64-mingw32/10.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find -lgcc_eh is there something else i'm missing. Thanks

Full error below

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\\peter\\.rustup\\toolchains\\stable-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\rsbegin.o" "C:\\Users\\peter\\Desktop\\Rust_Programming\\Code\\Opengl_Lessons\\learn-opengl-rs\\target\\debug\\build\\num-complex-1d9dcc0a2e0581fe\\build_script_build-1d9dcc0a2e0581fe.build_script_build.253ad390-cgu.0.rcgu.o" "C:\\Users\\peter\\Desktop\\Rust_Programming\\Code\\Opengl_Lessons\\learn-opengl-rs\\target\\debug\\build\\num-complex-1d9dcc0a2e0581fe\\build_script_build-1d9dcc0a2e0581fe.build_script_build.253ad390-cgu.1.rcgu.o" "C:\\Users\\peter\\Desktop\\Rust_Programming\\Code\\Opengl_Lessons\\learn-opengl-rs\\target\\debug\\build\\num-complex-1d9dcc0a2e0581fe\\build_script_build-1d9dcc0a2e0581fe.build_script_build.253ad390-cgu.10.rcgu.o" "C:\\Users\\peter\\Desktop\\Rust_Programming\\Code\\Opengl_Lessons\\learn-opengl-rs\\target\\debug\\build\\num-complex-1d9dcc0a2e0581fe\\build_script_build-1d9dcc0a2e0581fe.build_script_build.253ad390-cgu.11.rcgu.o" "C:\\Users\\peter\\Desktop\\Rust_Programming\\Code\\Opengl_Lessons\\learn-opengl-rs\\target\\debug\\build\\num-complex-1d9dcc0a2e0581fe\\build_script_build-1d9dcc0a2e0581fe.build_script_build.253ad390-cgu.12.rcgu.o" "C:\\Users\\peter\\Desktop\\Rust_Programming\\Code\\Opengl_Lessons\\learn-opengl-rs\\target\\debug\\build\\num-complex-1d9dcc0a2e0581fe\\build_script_build-1d9dcc0a2e0581fe.build_script_build.253ad390-cgu.13.rcgu.o" "C:\\Users\\peter\\Desktop\\Rust_Programming\\Code\\Opengl_Lessons\\learn-opengl-rs\\target\\debug\\build\\num-complex-1d9dcc0a2e0581fe\\build_script_build-1d9dcc0a2e0581fe.build_script_build.253ad390-cgu.14.rcgu.o" "C:\\Users\\peter\\Desktop\\Rust_Programming\\Code\\Opengl_Lessons\\learn-opengl-rs\\target\\debug\\build\\num-complex-1d9dcc0a2e0581fe\\build_script_build-1d9dcc0a2e0581fe.build_script_build.253ad390-cgu.15.rcgu.o" "C:\\Users\\peter\\Desktop\\Rust_Programming\\Code\\Opengl_Lessons\\learn-opengl-rs\\target\\debug\\build\\num-complex-1d9dcc0a2e0581fe\\build_script_build-1d9dcc0a2e0581fe.build_script_build.253ad390-cgu.2.rcgu.o" "C:\\Users\\peter\\Desktop\\Rust_Programming\\Code\\Opengl_Lessons\\learn-opengl-rs\\target\\debug\\build\\num-complex-1d9dcc0a2e0581fe\\build_script_build-1d9dcc0a2e0581fe.build_script_build.253ad390-cgu.3.rcgu.o" "C:\\Users\\peter\\Desktop\\Rust_Programming\\Code\\Opengl_Lessons\\learn-opengl-rs\\target\\debug\\build\\num-complex-1d9dcc0a2e0581fe\\build_script_build-1d9dcc0a2e0581fe.build_script_build.253ad390-cgu.4.rcgu.o" "C:\\Users\\peter\\Desktop\\Rust_Programming\\Code\\Opengl_Lessons\\learn-opengl-rs\\target\\debug\\build\\num-complex-1d9dcc0a2e0581fe\\build_script_build-1d9dcc0a2e0581fe.build_script_build.253ad390-cgu.5.rcgu.o" "C:\\Users\\peter\\Desktop\\Rust_Programming\\Code\\Opengl_Lessons\\learn-opengl-rs\\target\\debug\\build\\num-complex-1d9dcc0a2e0581fe\\build_script_build-1d9dcc0a2e0581fe.build_script_build.253ad390-cgu.6.rcgu.o" "C:\\Users\\peter\\Desktop\\Rust_Programming\\Code\\Opengl_Lessons\\learn-opengl-rs\\target\\debug\\build\\num-complex-1d9dcc0a2e0581fe\\build_script_build-1d9dcc0a2e0581fe.build_script_build.253ad390-cgu.7.rcgu.o" "C:\\Users\\peter\\Desktop\\Rust_Programming\\Code\\Opengl_Lessons\\learn-opengl-rs\\target\\debug\\build\\num-complex-1d9dcc0a2e0581fe\\build_script_build-1d9dcc0a2e0581fe.build_script_build.253ad390-cgu.8.rcgu.o" "C:\\Users\\peter\\Desktop\\Rust_Programming\\Code\\Opengl_Lessons\\learn-opengl-rs\\target\\debug\\build\\num-complex-1d9dcc0a2e0581fe\\build_script_build-1d9dcc0a2e0581fe.build_script_build.253ad390-cgu.9.rcgu.o" "C:\\Users\\peter\\Desktop\\Rust_Programming\\Code\\Opengl_Lessons\\learn-opengl-rs\\target\\debug\\build\\num-complex-1d9dcc0a2e0581fe\\build_script_build-1d9dcc0a2e0581fe.3xe3r320o5t2g1tt.rcgu.o" "-L" "C:\\Users\\peter\\Desktop\\Rust_Programming\\Code\\Opengl_Lessons\\learn-opengl-rs\\target\\debug\\deps" "-L" "C:\\Users\\peter\\.rustup\\toolchains\\stable-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib" "-Wl,--start-group" "-Wl,-Bstatic" "C:\\Users\\peter\\.rustup\\toolchains\\stable-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\libstd-9075868f02c39105.rlib" "C:\\Users\\peter\\.rustup\\toolchains\\stable-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\libpanic_unwind-9428c324e8b3666b.rlib" "C:\\Users\\peter\\.rustup\\toolchains\\stable-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\libobject-4a98078f239020c3.rlib" "C:\\Users\\peter\\.rustup\\toolchains\\stable-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\libmemchr-6757767b31fe77e1.rlib" "C:\\Users\\peter\\.rustup\\toolchains\\stable-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\libaddr2line-c0d2da11c6d2d6c0.rlib" "C:\\Users\\peter\\.rustup\\toolchains\\stable-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\libgimli-9e7d4e8bc407ad15.rlib" "C:\\Users\\peter\\.rustup\\toolchains\\stable-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\librustc_demangle-da42fc4024365a2c.rlib" "C:\\Users\\peter\\.rustup\\toolchains\\stable-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\libstd_detect-89ac367f33223d21.rlib" "C:\\Users\\peter\\.rustup\\toolchains\\stable-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\libhashbrown-d506a327105b7f9b.rlib" "C:\\Users\\peter\\.rustup\\toolchains\\stable-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\librustc_std_workspace_alloc-59684a51af165391.rlib" "C:\\Users\\peter\\.rustup\\toolchains\\stable-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\libunwind-76b6cbab8df641fe.rlib" "C:\\Users\\peter\\.rustup\\toolchains\\stable-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\libcfg_if-1f71fd1e2c1fff1d.rlib" "C:\\Users\\peter\\.rustup\\toolchains\\stable-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\liblibc-941c197b7acaf3f9.rlib" "C:\\Users\\peter\\.rustup\\toolchains\\stable-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\liballoc-ed65eeea771bb49a.rlib" "C:\\Users\\peter\\.rustup\\toolchains\\stable-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\librustc_std_workspace_core-206ecc270c58e4f3.rlib" "C:\\Users\\peter\\.rustup\\toolchains\\stable-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\libcore-1063c1f162c501e3.rlib" "-Wl,--end-group" "C:\\Users\\peter\\.rustup\\toolchains\\stable-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\libcompiler_builtins-3f91c8bbaf203c3c.rlib" "-Wl,-Bdynamic" "-lkernel32" "-lws2_32" "-lbcrypt" "-ladvapi32" "-luserenv" "-lkernel32" "-lgcc_eh" "-l:libpthread.a" "-lmsvcrt" "-lmingwex" "-lmingw32" "-lgcc" "-lmsvcrt" "-luser32" "-lkernel32" "-Wl,--nxcompat" "-L" "C:\\Users\\peter\\.rustup\\toolchains\\stable-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib" "-o" "C:\\Users\\peter\\Desktop\\Rust_Programming\\Code\\Opengl_Lessons\\learn-opengl-rs\\target\\debug\\build\\num-complex-1d9dcc0a2e0581fe\\build_script_build-1d9dcc0a2e0581fe.exe" "-Wl,--gc-sections" "-no-pie" "-nodefaultlibs" "C:\\Users\\peter\\.rustup\\toolchains\\stable-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\rsend.o"
  = note: C:/TDM-GCC-64/bin/../lib/gcc/x86_64-w64-mingw32/10.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find -lgcc_eh
          collect2.exe: error: ld returned 1 exit status

CodePudding user response:

First of all: TDM, Cygwin, and 2019-redestributable are three different tool-chains. Similar, but different, you should not mix them. You need to choose one environment, meaning MinGW of TDM flavor, Cygwin, or Visual Studio. And stick to them. It is sometimes possible to reuse some pieces of tool chains, but not easy and require good understanding of both tool-chains.

Second: read the error message "ld.exe: cannot find -lgcc_eh" - that means your linker cannot find a library gcc_eh. What is that library? Which project you are trying to compile?
Go to the projects documentation, find there installation instructions and do as written. This instruction will (most likely) have suggestion which tool-chain to use too.

  • Related