Substrate-node-template cargo build failed

How can I fix it?

E:\Workspace\Blockchain\substrate-node-template>cargo build
   Compiling wasmtime-runtime v1.0.2
   Compiling wasmtime-cranelift v1.0.2
   Compiling wasmtime-cache v1.0.2
   Compiling base16ct v0.1.1
   Compiling remove_dir_all v0.5.3
   Compiling fastrand v1.8.0
   Compiling sp-core-hashing-proc-macro v5.0.0 (https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.37#946507ba)
   Compiling sp-version-proc-macro v4.0.0-dev (https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.37#946507ba)
   Compiling sp-panic-handler v5.0.0 (https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.37#946507ba)
   Compiling spki v0.6.0
   Compiling prost-derive v0.11.6
   Compiling sp-api-proc-macro v4.0.0-dev (https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.37#946507ba)
error[E0432]: unresolved import `windows_sys::Win32::Foundation`
  --> C:\Users\Administrator\.cargo\registry\src\index.crates.io-6f17d22bba15001f\wasmtime-runtime-1.0.2\src\mmap.rs:90:37
   |
90 |             use windows_sys::Win32::Foundation::*;
   |                                     ^^^^^^^^^^ could not find `Foundation` in `Win32`

error[E0432]: unresolved import `windows_sys::Win32::Foundation`
 --> C:\Users\Administrator\.cargo\registry\src\index.crates.io-6f17d22bba15001f\wasmtime-runtime-1.0.2\src\traphandlers\windows.rs:3:25
  |
3 | use windows_sys::Win32::Foundation::*;
  |                         ^^^^^^^^^^ could not find `Foundation` in `Win32`

error[E0412]: cannot find type `EXCEPTION_POINTERS` in this scope
 --> C:\Users\Administrator\.cargo\registry\src\index.crates.io-6f17d22bba15001f\wasmtime-runtime-1.0.2\src\traphandlers\windows.rs:8:42
  |
8 | pub type SignalHandler<'a> = dyn Fn(*mut EXCEPTION_POINTERS) -> bool + Send + Sync + 'a;
  |                                          ^^^^^^^^^^^^^^^^^^ not found in this scope

error[E0412]: cannot find type `EXCEPTION_POINTERS` in this scope
  --> C:\Users\Administrator\.cargo\registry\src\index.crates.io-6f17d22bba15001f\wasmtime-runtime-1.0.2\src\traphandlers\windows.rs:22:66
   |
22 | unsafe extern "system" fn exception_handler(exception_info: *mut EXCEPTION_POINTERS) -> i32 {
   |                                                                  ^^^^^^^^^^^^^^^^^^ not found in this scope

error[E0425]: cannot find value `EXCEPTION_ACCESS_VIOLATION` in this scope
  --> C:\Users\Administrator\.cargo\registry\src\index.crates.io-6f17d22bba15001f\wasmtime-runtime-1.0.2\src\traphandlers\windows.rs:27:32
   |
27 |     if record.ExceptionCode != EXCEPTION_ACCESS_VIOLATION
   |                                ^^^^^^^^^^^^^^^^^^^^^^^^^^ not found in this scope

error[E0425]: cannot find value `EXCEPTION_ILLEGAL_INSTRUCTION` in this scope
  --> C:\Users\Administrator\.cargo\registry\src\index.crates.io-6f17d22bba15001f\wasmtime-runtime-1.0.2\src\traphandlers\windows.rs:28:36
   |
28 |         && record.ExceptionCode != EXCEPTION_ILLEGAL_INSTRUCTION
   |                                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ not found in this scope

error[E0425]: cannot find value `EXCEPTION_INT_DIVIDE_BY_ZERO` in this scope
  --> C:\Users\Administrator\.cargo\registry\src\index.crates.io-6f17d22bba15001f\wasmtime-runtime-1.0.2\src\traphandlers\windows.rs:29:36
   |
29 |         && record.ExceptionCode != EXCEPTION_INT_DIVIDE_BY_ZERO
   |                                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ not found in this scope

error[E0425]: cannot find value `EXCEPTION_INT_OVERFLOW` in this scope
  --> C:\Users\Administrator\.cargo\registry\src\index.crates.io-6f17d22bba15001f\wasmtime-runtime-1.0.2\src\traphandlers\windows.rs:30:36
   |
30 |         && record.ExceptionCode != EXCEPTION_INT_OVERFLOW
   |                                    ^^^^^^^^^^^^^^^^^^^^^^ not found in this scope

error[E0425]: cannot find function, tuple struct or tuple variant `VirtualFree` in this scope
  --> C:\Users\Administrator\.cargo\registry\src\index.crates.io-6f17d22bba15001f\wasmtime-runtime-1.0.2\src\instance\allocator\pooling\windows.rs:22:17
   |
22 |     if unsafe { VirtualFree(addr as _, len, MEM_DECOMMIT) } == 0 {
   |                 ^^^^^^^^^^^ not found in this scope

error[E0425]: cannot find function, tuple struct or tuple variant `CreateFileMappingW` in this scope
   --> C:\Users\Administrator\.cargo\registry\src\index.crates.io-6f17d22bba15001f\wasmtime-runtime-1.0.2\src\mmap.rs:114:31
    |
114 |                 let mapping = CreateFileMappingW(
    |                               ^^^^^^^^^^^^^^^^^^ not found in this scope

error[E0425]: cannot find function, tuple struct or tuple variant `MapViewOfFile` in this scope
   --> C:\Users\Administrator\.cargo\registry\src\index.crates.io-6f17d22bba15001f\wasmtime-runtime-1.0.2\src\mmap.rs:129:27
    |
129 |                 let ptr = MapViewOfFile(mapping, FILE_MAP_READ | FILE_MAP_EXECUTE, 0, 0, len);
    |                           ^^^^^^^^^^^^^ not found in this scope

error[E0425]: cannot find function, tuple struct or tuple variant `CloseHandle` in this scope
   --> C:\Users\Administrator\.cargo\registry\src\index.crates.io-6f17d22bba15001f\wasmtime-runtime-1.0.2\src\mmap.rs:131:17
    |
131 |                 CloseHandle(mapping);
    |                 ^^^^^^^^^^^ not found in this scope

   Compiling pkcs8 v0.9.0
error[E0425]: cannot find function, tuple struct or tuple variant `VirtualProtect` in this scope
   --> C:\Users\Administrator\.cargo\registry\src\index.crates.io-6f17d22bba15001f\wasmtime-runtime-1.0.2\src\mmap.rs:146:20
    |
146 |                 if VirtualProtect(ret.ptr as *mut _, ret.len, PAGE_READONLY, &mut old) == 0 {
    |                    ^^^^^^^^^^^^^^ not found in this scope

error[E0425]: cannot find function, tuple struct or tuple variant `VirtualProtect` in this scope
   --> C:\Users\Administrator\.cargo\registry\src\index.crates.io-6f17d22bba15001f\wasmtime-runtime-1.0.2\src\mmap.rs:396:17
    |
396 |                 VirtualProtect(base, len, PAGE_WRITECOPY, &mut old)
    |                 ^^^^^^^^^^^^^^ not found in this scope

error[E0425]: cannot find function, tuple struct or tuple variant `VirtualProtect` in this scope
   --> C:\Users\Administrator\.cargo\registry\src\index.crates.io-6f17d22bba15001f\wasmtime-runtime-1.0.2\src\mmap.rs:398:17
    |
398 |                 VirtualProtect(base, len, PAGE_READWRITE, &mut old)
    |                 ^^^^^^^^^^^^^^ not found in this scope

error[E0425]: cannot find function, tuple struct or tuple variant `VirtualProtect` in this scope
   --> C:\Users\Administrator\.cargo\registry\src\index.crates.io-6f17d22bba15001f\wasmtime-runtime-1.0.2\src\mmap.rs:432:26
    |
432 |             let result = VirtualProtect(base, len, PAGE_EXECUTE_READ, &mut old);
    |                          ^^^^^^^^^^^^^^ not found in this scope

   Compiling tempfile v3.3.0
error[E0425]: cannot find function, tuple struct or tuple variant `VirtualFree` in this scope
   --> C:\Users\Administrator\.cargo\registry\src\index.crates.io-6f17d22bba15001f\wasmtime-runtime-1.0.2\src\mmap.rs:468:34
    |
468 |                 let r = unsafe { VirtualFree(self.ptr as *mut c_void, 0, MEM_RELEASE) };
    |                                  ^^^^^^^^^^^ not found in this scope

error[E0425]: cannot find function, tuple struct or tuple variant `UnmapViewOfFile` in this scope
   --> C:\Users\Administrator\.cargo\registry\src\index.crates.io-6f17d22bba15001f\wasmtime-runtime-1.0.2\src\mmap.rs:471:34
    |
471 |                 let r = unsafe { UnmapViewOfFile(self.ptr as *mut c_void) };
    |                                  ^^^^^^^^^^^^^^^ not found in this scope

   Compiling socket2 v0.4.7
error[E0425]: cannot find function, tuple struct or tuple variant `AddVectoredExceptionHandler` in this scope
   --> C:\Users\Administrator\.cargo\registry\src\index.crates.io-6f17d22bba15001f\wasmtime-runtime-1.0.2\src\traphandlers\windows.rs:14:8
    |
14  |     if AddVectoredExceptionHandler(1, Some(exception_handler)).is_null() {
    |        ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: a function with a similar name exists: `RemoveVectoredExceptionHandler`
    |
   ::: C:\Users\Administrator\.cargo\registry\src\index.crates.io-6f17d22bba15001f\windows-sys-0.36.1\src\Windows\Win32\System\Diagnostics\Debug\mod.rs:305:5
    |
305 |     pub fn RemoveVectoredExceptionHandler(handle: *const ::core::ffi::c_void) -> u32;
    |     -------------------------------------------------------------------------------- similarly named function `RemoveVectoredExceptionHandler` defined here

error[E0618]: expected function, found `impl Fn(&SignalHandler) -> bool`
   --> C:\Users\Administrator\.cargo\registry\src\index.crates.io-6f17d22bba15001f\wasmtime-runtime-1.0.2\src\traphandlers.rs:433:25
    |
412 |         call_handler: impl Fn(&SignalHandler) -> bool,
    |         ------------ `call_handler` has type `impl Fn(&SignalHandler) -> bool`
...
433 |             if unsafe { call_handler(&*handler) } {
    |                         ^^^^^^^^^^^^-----------
    |                         |
    |                         call expression requires function

Some errors have detailed explanations: E0412, E0425, E0432, E0618.
For more information about an error, try `rustc --explain E0412`.
error: could not compile `wasmtime-runtime` due to 20 previous errors
warning: build failed, waiting for other jobs to finish...
error[E0425]: cannot find function, tuple struct or tuple variant `GetCurrentThread` in this scope
   --> C:\Users\Administrator\.cargo\registry\src\index.crates.io-6f17d22bba15001f\wasmtime-cache-1.0.2\src\worker.rs:240:17
    |
240 |                 GetCurrentThread(),
    |                 ^^^^^^^^^^^^^^^^ help: a function with a similar name exists: `GetCurrentThreadId`
    |
   ::: C:\Users\Administrator\.cargo\registry\src\index.crates.io-6f17d22bba15001f\windows-sys-0.36.1\src\Windows\Win32\System\Threading\mod.rs:283:5
    |
283 |     pub fn GetCurrentThreadId() -> u32;
    |     ---------------------------------- similarly named function `GetCurrentThreadId` defined here

error[E0425]: cannot find function, tuple struct or tuple variant `SetThreadPriority` in this scope
    --> C:\Users\Administrator\.cargo\registry\src\index.crates.io-6f17d22bba15001f\wasmtime-cache-1.0.2\src\worker.rs:239:13
     |
239  |             SetThreadPriority(
     |             ^^^^^^^^^^^^^^^^^ help: a constant with a similar name exists: `UmsThreadPriority`
     |
    ::: C:\Users\Administrator\.cargo\registry\src\index.crates.io-6f17d22bba15001f\windows-sys-0.36.1\src\Windows\Win32\System\Threading\mod.rs:1725:1
     |
1725 | pub const UmsThreadPriority: RTL_UMS_THREAD_INFO_CLASS = 2i32;
     | ------------------------------------------------------ similarly named constant `UmsThreadPriority` defined here

For more information about this error, try `rustc --explain E0425`.
error: could not compile `wasmtime-cache` due to 2 previous errors

Please, help me.

I think you must use the WSL in Windows:

Thank you for your help. I will try.

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.