Search code examples
gccrustrust-cargorust-tokioreqwest

error linking with x86_64-w64-mingw32-gcc failed: exit code: 1


I'm trying to make an https request in rust and I have this code:

use reqwest::header::{AUTHORIZATION, ACCEPT};

// tokio let's us use "async" on our main function
#[tokio::main]
async fn main() {
    let api_url = "https://api.curseforge.com";
    let url = format!("{api_url}/v1/mods/556448/files/3984913");
    
    // chaining .await will yield our query result
    let client = reqwest::Client::new();
    let response = client
        .get(url)
        .header(AUTHORIZATION, "API_KEY")
        .header(ACCEPT, "application/json");
        
    println!("Success! {:?}", response);
}
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\\rodri\\.rustup\\toolchains\\stable-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\self-contained\\crt2.o" "C:\\Users\\rodri\\.rustup\\toolchains\\stable-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\rsbegin.o" "C:\\Users\\rodri\\AppData\\Local\\Temp\\rustcHfawG0\\symbols.o" "C:\\Users\\rodri\\Desktop\\hopper\\target\\debug\\deps\\hopper-9669c6a1b1ad991e.121a7bvfzps9fulw.rcgu.o" "C:\\Users\\rodri\\Desktop\\hopper\\target\\debug\\deps\\hopper-9669c6a1b1ad991e.1do7n9y4ri0mibo1.rcgu.o" "C:\\Users\\rodri\\Desktop\\hopper\\target\\debug\\deps\\hopper-9669c6a1b1ad991e.1ow8352pzd1is1n1.rcgu.o" "C:\\Users\\rodri\\Desktop\\hopper\\target\\debug\\deps\\hopper-9669c6a1b1ad991e.1qnopllocovaqct6.rcgu.o" "C:\\Users\\rodri\\Desktop\\hopper\\target\\debug\\deps\\hopper-9669c6a1b1ad991e.21iaug48qu05qawp.rcgu.o" "C:\\Users\\rodri\\Desktop\\hopper\\target\\debug\\deps\\hopper-9669c6a1b1ad991e.2389lsjspqenjab5.rcgu.o" "C:\\Users\\rodri\\Desktop\\hopper\\target\\debug\\deps\\hopper-9669c6a1b1ad991e.2ad5bu9bpgn2msvi.rcgu.o" "C:\\Users\\rodri\\Desktop\\hopper\\target\\debug\\deps\\hopper-9669c6a1b1ad991e.2upmxq85jjbss75f.rcgu.o" "C:\\Users\\rodri\\Desktop\\hopper\\target\\debug\\deps\\hopper-9669c6a1b1ad991e.34pw1sajj20fy7ya.rcgu.o" "C:\\Users\\rodri\\Desktop\\hopper\\target\\debug\\deps\\hopper-9669c6a1b1ad991e.35bid4ycrdjd77w4.rcgu.o" "C:\\Users\\rodri\\Desktop\\hopper\\target\\debug\\deps\\hopper-9669c6a1b1ad991e.364xjl1io1cw2wn5.rcgu.o" "C:\\Users\\rodri\\Desktop\\hopper\\target\\debug\\deps\\hopper-9669c6a1b1ad991e.386vm1wfh55izwq2.rcgu.o" "C:\\Users\\rodri\\Desktop\\hopper\\target\\debug\\deps\\hopper-9669c6a1b1ad991e.3fum8kjgi7sb9pyh.rcgu.o" "C:\\Users\\rodri\\Desktop\\hopper\\target\\debug\\deps\\hopper-9669c6a1b1ad991e.3gyr4r22wes5sp3p.rcgu.o" "C:\\Users\\rodri\\Desktop\\hopper\\target\\debug\\deps\\hopper-9669c6a1b1ad991e.3hc5n6fei0mhdq5b.rcgu.o" "C:\\Users\\rodri\\Desktop\\hopper\\target\\debug\\deps\\hopper-9669c6a1b1ad991e.3k4usr8j5ykoqx28.rcgu.o" "C:\\Users\\rodri\\Desktop\\hopper\\target\\debug\\deps\\hopper-9669c6a1b1ad991e.3qdxpow0ssn01170.rcgu.o" "C:\\Users\\rodri\\Desktop\\hopper\\target\\debug\\deps\\hopper-9669c6a1b1ad991e.3qqcxh64hzeobcru.rcgu.o" "C:\\Users\\rodri\\Desktop\\hopper\\target\\debug\\deps\\hopper-9669c6a1b1ad991e.3re1u57xnnpw2q9c.rcgu.o" "C:\\Users\\rodri\\Desktop\\hopper\\target\\debug\\deps\\hopper-9669c6a1b1ad991e.3tr4hbtqcy5wjci9.rcgu.o" "C:\\Users\\rodri\\Desktop\\hopper\\target\\debug\\deps\\hopper-9669c6a1b1ad991e.44nwgfrm0e330alk.rcgu.o" "C:\\Users\\rodri\\Desktop\\hopper\\target\\debug\\deps\\hopper-9669c6a1b1ad991e.4a3v6az2w6d2gv1g.rcgu.o" "C:\\Users\\rodri\\Desktop\\hopper\\target\\debug\\deps\\hopper-9669c6a1b1ad991e.4c826yh4791rz6wa.rcgu.o" "C:\\Users\\rodri\\Desktop\\hopper\\target\\debug\\deps\\hopper-9669c6a1b1ad991e.4kibvrpgbsrvrxi0.rcgu.o" "C:\\Users\\rodri\\Desktop\\hopper\\target\\debug\\deps\\hopper-9669c6a1b1ad991e.4nu8nskztsy4rj6y.rcgu.o" "C:\\Users\\rodri\\Desktop\\hopper\\target\\debug\\deps\\hopper-9669c6a1b1ad991e.4rbobhn6atmhxns9.rcgu.o" "C:\\Users\\rodri\\Desktop\\hopper\\target\\debug\\deps\\hopper-9669c6a1b1ad991e.50ah5uoiqoubs0t0.rcgu.o" "C:\\Users\\rodri\\Desktop\\hopper\\target\\debug\\deps\\hopper-9669c6a1b1ad991e.53ghgmt7rwe6i1xj.rcgu.o" "C:\\Users\\rodri\\Desktop\\hopper\\target\\debug\\deps\\hopper-9669c6a1b1ad991e.5dyvckopt3y6f8ys.rcgu.o" "C:\\Users\\rodri\\Desktop\\hopper\\target\\debug\\deps\\hopper-9669c6a1b1ad991e.8kx6bhg7ag96021.rcgu.o" "C:\\Users\\rodri\\Desktop\\hopper\\target\\debug\\deps\\hopper-9669c6a1b1ad991e.aboyqmsw8nioqoz.rcgu.o" "C:\\Users\\rodri\\Desktop\\hopper\\target\\debug\\deps\\hopper-9669c6a1b1ad991e.e3hxt099wdl6d44.rcgu.o" "C:\\Users\\rodri\\Desktop\\hopper\\target\\debug\\deps\\hopper-9669c6a1b1ad991e.kt8qcrk9c91pt2i.rcgu.o" "C:\\Users\\rodri\\Desktop\\hopper\\target\\debug\\deps\\hopper-9669c6a1b1ad991e.4oajgp7gmduo4zsn.rcgu.o" "-L" "C:\\Users\\rodri\\Desktop\\hopper\\target\\debug\\deps" "-L" "C:\\Users\\rodri\\.cargo\\registry\\src\\github.com-1ecc6299db9ec823\\windows_x86_64_gnu-0.42.1\\lib" "-L" "C:\\Users\\rodri\\.cargo\\registry\\src\\github.com-1ecc6299db9ec823\\winapi-x86_64-pc-windows-gnu-0.4.0\\lib" "-L" "C:\\Users\\rodri\\.rustup\\toolchains\\stable-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib" "-Wl,-Bstatic" "C:\\Users\\rodri\\Desktop\\hopper\\target\\debug\\deps\\libreqwest-6350fc475536af9c.rlib" "C:\\Users\\rodri\\Desktop\\hopper\\target\\debug\\deps\\libhyper_tls-045d31f108593e38.rlib" "C:\\Users\\rodri\\Desktop\\hopper\\target\\debug\\deps\\libserde_urlencoded-32c0d5a6b76d9b04.rlib" "C:\\Users\\rodri\\Desktop\\hopper\\target\\debug\\deps\\libbase64-7e6de740ea1ba062.rlib" 
"C:\\Users\\rodri\\Desktop\\hopper\\target\\debug\\deps\\libwinreg-2132bac5434b9b6a.rlib" "C:\\Users\\rodri\\Desktop\\hopper\\target\\debug\\deps\\libipnet-267731b2d0038ff4.rlib" "C:\\Users\\rodri\\Desktop\\hopper\\target\\debug\\deps\\libtokio_native_tls-223c7194fd3e1832.rlib" "C:\\Users\\rodri\\Desktop\\hopper\\target\\debug\\deps\\libmime-05a366f20309fcd6.rlib" "C:\\Users\\rodri\\Desktop\\hopper\\target\\debug\\deps\\libencoding_rs-bb6ec43d794d4c9f.rlib" "C:\\Users\\rodri\\Desktop\\hopper\\target\\debug\\deps\\libserde_json-02555686be65510e.rlib" "C:\\Users\\rodri\\Desktop\\hopper\\target\\debug\\deps\\libryu-d89f69d6ca880805.rlib" "C:\\Users\\rodri\\Desktop\\hopper\\target\\debug\\deps\\libserde-284c0cfc74769160.rlib" "C:\\Users\\rodri\\Desktop\\hopper\\target\\debug\\deps\\libnative_tls-ed7a660bd6dc49f3.rlib" "C:\\Users\\rodri\\Desktop\\hopper\\target\\debug\\deps\\libschannel-159174fefb215947.rlib" "C:\\Users\\rodri\\Desktop\\hopper\\target\\debug\\deps\\libhyper-b8e62d73a262631d.rlib" "C:\\Users\\rodri\\Desktop\\hopper\\target\\debug\\deps\\libwant-a609362a1ea01f53.rlib" "C:\\Users\\rodri\\Desktop\\hopper\\target\\debug\\deps\\libtry_lock-54737669dae0c49c.rlib" "C:\\Users\\rodri\\Desktop\\hopper\\target\\debug\\deps\\libhttparse-530239e0e65e5783.rlib" "C:\\Users\\rodri\\Desktop\\hopper\\target\\debug\\deps\\libh2-c4a2f85d0008ff61.rlib" "C:\\Users\\rodri\\Desktop\\hopper\\target\\debug\\deps\\libindexmap-e15818bc248cf1a4.rlib" "C:\\Users\\rodri\\Desktop\\hopper\\target\\debug\\deps\\libhashbrown-3eb205f33966e2d4.rlib" "C:\\Users\\rodri\\Desktop\\hopper\\target\\debug\\deps\\libtokio_util-da26853c9430edf1.rlib" "C:\\Users\\rodri\\Desktop\\hopper\\target\\debug\\deps\\libtower_service-78223f7c8cec28b2.rlib" "C:\\Users\\rodri\\Desktop\\hopper\\target\\debug\\deps\\libtracing-a2339d592b2dfc09.rlib" "C:\\Users\\rodri\\Desktop\\hopper\\target\\debug\\deps\\libtracing_core-e43d4759beb33094.rlib" "C:\\Users\\rodri\\Desktop\\hopper\\target\\debug\\deps\\libonce_cell-ee14036f8c111fbe.rlib" "C:\\Users\\rodri\\Desktop\\hopper\\target\\debug\\deps\\libfutures_util-b1ea6f3a6257ddc9.rlib" "C:\\Users\\rodri\\Desktop\\hopper\\target\\debug\\deps\\libfutures_io-62997d3c689711c8.rlib" "C:\\Users\\rodri\\Desktop\\hopper\\target\\debug\\deps\\libslab-8e2622f3c5f1211a.rlib" "C:\\Users\\rodri\\Desktop\\hopper\\target\\debug\\deps\\libfutures_channel-72dd492f16db6183.rlib" "C:\\Users\\rodri\\Desktop\\hopper\\target\\debug\\deps\\libfutures_sink-6b509305109f3868.rlib" "C:\\Users\\rodri\\Desktop\\hopper\\target\\debug\\deps\\libfutures_task-1f716df10d29cb70.rlib" "C:\\Users\\rodri\\Desktop\\hopper\\target\\debug\\deps\\libpin_utils-bb3d077ca2edb965.rlib" "C:\\Users\\rodri\\Desktop\\hopper\\target\\debug\\deps\\libtokio-fcff56c419690a10.rlib" "C:\\Users\\rodri\\Desktop\\hopper\\target\\debug\\deps\\libnum_cpus-aeefeea25a7d9ac0.rlib" "C:\\Users\\rodri\\Desktop\\hopper\\target\\debug\\deps\\libsocket2-e5ab9d70ab7f118f.rlib" "C:\\Users\\rodri\\Desktop\\hopper\\target\\debug\\deps\\libwinapi-9740659a6fdaa48f.rlib" "C:\\Users\\rodri\\Desktop\\hopper\\target\\debug\\deps\\libmemchr-7ed03600c5b9d734.rlib" "C:\\Users\\rodri\\Desktop\\hopper\\target\\debug\\deps\\libwindows_sys-8adaf8a51286b0ee.rlib" "C:\\Users\\rodri\\Desktop\\hopper\\target\\debug\\deps\\libmio-cba9df6bc53b9805.rlib" "C:\\Users\\rodri\\Desktop\\hopper\\target\\debug\\deps\\libparking_lot-7265ad702e67432a.rlib" "C:\\Users\\rodri\\Desktop\\hopper\\target\\debug\\deps\\libparking_lot_core-6fc50acede269800.rlib" "C:\\Users\\rodri\\Desktop\\hopper\\target\\debug\\deps\\libwindows_sys-fb85ddfcc26ee016.rlib" "C:\\Users\\rodri\\Desktop\\hopper\\target\\debug\\deps\\libsmallvec-b4555a3e4f378f7d.rlib" "C:\\Users\\rodri\\Desktop\\hopper\\target\\debug\\deps\\liblock_api-e229e11f23dcc3ba.rlib" "C:\\Users\\rodri\\Desktop\\hopper\\target\\debug\\deps\\libscopeguard-e23846118fa3110d.rlib" "C:\\Users\\rodri\\Desktop\\hopper\\target\\debug\\deps\\libhttp_body-7538e3b1acf68c2c.rlib" "C:\\Users\\rodri\\Desktop\\hopper\\target\\debug\\deps\\libpin_project_lite-b049ea84f88ddefa.rlib" "C:\\Users\\rodri\\Desktop\\hopper\\target\\debug\\deps\\liblog-a5a95fbc519cce77.rlib" "C:\\Users\\rodri\\Desktop\\hopper\\target\\debug\\deps\\libcfg_if-466540c90383d5b2.rlib" "C:\\Users\\rodri\\Desktop\\hopper\\target\\debug\\deps\\libfutures_core-d8e1984756226eec.rlib" "C:\\Users\\rodri\\Desktop\\hopper\\target\\debug\\deps\\liburl-30c25b5e442f5afb.rlib" "C:\\Users\\rodri\\Desktop\\hopper\\target\\debug\\deps\\libidna-77a923dd66e3af04.rlib" "C:\\Users\\rodri\\Desktop\\hopper\\target\\debug\\deps\\libunicode_normalization-a33a5a30433b7170.rlib" "C:\\Users\\rodri\\Desktop\\hopper\\target\\debug\\deps\\libtinyvec-7e5861d79defe41a.rlib" "C:\\Users\\rodri\\Desktop\\hopper\\target\\debug\\deps\\libtinyvec_macros-1fe79f5ee570c6cf.rlib" "C:\\Users\\rodri\\Desktop\\hopper\\target\\debug\\deps\\libunicode_bidi-1a51110baed36529.rlib" "C:\\Users\\rodri\\Desktop\\hopper\\target\\debug\\deps\\libform_urlencoded-d1a41e4b45637088.rlib" "C:\\Users\\rodri\\Desktop\\hopper\\target\\debug\\deps\\libpercent_encoding-d7d06e2092f56431.rlib" "C:\\Users\\rodri\\Desktop\\hopper\\target\\debug\\deps\\libhttp-2512d5fe34c05920.rlib" "C:\\Users\\rodri\\Desktop\\hopper\\target\\debug\\deps\\libitoa-3aaafe85bbdd1975.rlib" "C:\\Users\\rodri\\Desktop\\hopper\\target\\debug\\deps\\libbytes-257930e1731f9ee9.rlib" "C:\\Users\\rodri\\Desktop\\hopper\\target\\debug\\deps\\libfnv-5006a154943ab56b.rlib" "C:\\Users\\rodri\\.rustup\\toolchains\\stable-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\libstd-a73802b277b8e653.rlib" "C:\\Users\\rodri\\.rustup\\toolchains\\stable-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\libpanic_unwind-b58cdaac8171c254.rlib" "C:\\Users\\rodri\\.rustup\\toolchains\\stable-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\libobject-d08779a03ea819f2.rlib" "C:\\Users\\rodri\\.rustup\\toolchains\\stable-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\libmemchr-e0af7175c5b3f4bd.rlib" "C:\\Users\\rodri\\.rustup\\toolchains\\stable-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\libaddr2line-6d52d94befc8840f.rlib" "C:\\Users\\rodri\\.rustup\\toolchains\\stable-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\libgimli-4a08728bb43f7f3e.rlib" "C:\\Users\\rodri\\.rustup\\toolchains\\stable-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\librustc_demangle-cabbabd1fb98ae23.rlib" "C:\\Users\\rodri\\.rustup\\toolchains\\stable-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\libstd_detect-9e6f2a8e1c9b8033.rlib" "C:\\Users\\rodri\\.rustup\\toolchains\\stable-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\libhashbrown-d69df6007b729193.rlib" "C:\\Users\\rodri\\.rustup\\toolchains\\stable-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\libminiz_oxide-01377e8ce16592c7.rlib" "C:\\Users\\rodri\\.rustup\\toolchains\\stable-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\libadler-55ef25959858fd57.rlib" "C:\\Users\\rodri\\.rustup\\toolchains\\stable-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\librustc_std_workspace_alloc-2472e5240618b585.rlib" "C:\\Users\\rodri\\.rustup\\toolchains\\stable-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\libunwind-2afe724482cf62fa.rlib" "C:\\Users\\rodri\\.rustup\\toolchains\\stable-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\libcfg_if-48b872d5a2bb0096.rlib" "C:\\Users\\rodri\\.rustup\\toolchains\\stable-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\liblibc-dee7a4d657e124bd.rlib" "C:\\Users\\rodri\\.rustup\\toolchains\\stable-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\liballoc-4f26e328114b6510.rlib" "C:\\Users\\rodri\\.rustup\\toolchains\\stable-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\librustc_std_workspace_core-9848a62a497bd0b7.rlib" "C:\\Users\\rodri\\.rustup\\toolchains\\stable-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\libcore-4c56368b40b44789.rlib" "C:\\Users\\rodri\\.rustup\\toolchains\\stable-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\libcompiler_builtins-82abfd2e7a4dff39.rlib" "-Wl,-Bdynamic" "-lwinapi_advapi32" "-lwinapi_cfgmgr32" "-lwinapi_fwpuclnt" "-lwinapi_kernel32" "-lwinapi_ntdll" "-lwinapi_user32" "-lwinapi_ws2_32" "-lwindows" "-lntdll" "-lwindows" "-lkernel32" "-ladvapi32" "-luserenv" "-lkernel32" "-lws2_32" "-lbcrypt" "-lgcc_eh" "-l:libpthread.a" "-lmsvcrt" "-lmingwex" "-lmingw32" "-lgcc" "-lmsvcrt" "-luser32" "-lkernel32" "-Wl,--nxcompat" "-nostartfiles" "-L" "C:\\Users\\rodri\\.rustup\\toolchains\\stable-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib" "-L" "C:\\Users\\rodri\\.rustup\\toolchains\\stable-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\self-contained" "-o" "C:\\Users\\rodri\\Desktop\\hopper\\target\\debug\\deps\\hopper-9669c6a1b1ad991e.exe" "-Wl,--gc-sections" "-no-pie" "-nodefaultlibs" "C:\\Users\\rodri\\.rustup\\toolchains\\stable-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\rsend.o"
  = note: ld: cannot find -lntdll


error: could not compile `hopper` due to previous error

I think this is a problem with cargo and reqwest, because cargo run worked perfectly before I added reqwest and rustc worked perfectly.


Solution

  • This does not seem to be a mistake in your code, rather the linker ld is looking for a library ntdll which it is unable to find.

    For a more detailed answer look at This answer which should explain how to fix your problem.

    ntdll is explained further here