首页 > 解决方案 > wasm-pack build report error: could not compile `net2`

问题描述

i use try to use rustwasm refered https://rustwasm.github.io/book/game-of-life/hello-world.html,all worked fine. but when i add reqwest = "0.9.22" to Cargo.toml,then execute wasm-pack build command in my project,the compiler reports such an error:

$ wasm-pack build > log.log
[INFO]: Checking for the Wasm target...
[INFO]: Compiling to Wasm...
Compiling net2 v0.2.33
Compiling openssl-sys v0.9.53
Compiling http v0.1.21
Compiling string v0.2.1
Compiling tokio-buf v0.1.1
Compiling backtrace v0.3.40
Compiling mime_guess v2.0.1
Compiling cookie v0.12.0
error[E0432]: unresolved import sys
--> D:\cargo\registry\src\github.com-1ecc6299db9ec823\net2-0.2.33\src\tcp.rs:18:5
|
18 | use sys::c;
| ^^^ maybe a missing crate sys?

error[E0432]: unresolved import sys
--> D:\cargo\registry\src\github.com-1ecc6299db9ec823\net2-0.2.33\src\udp.rs:18:5
|
18 | use sys::c;
| ^^^ maybe a missing crate sys?

error[E0432]: unresolved import sys
--> D:\cargo\registry\src\github.com-1ecc6299db9ec823\net2-0.2.33\src\socket.rs:22:5
|
22 | use sys;
| ^^^ no sys in the root

error[E0432]: unresolved import sys
--> D:\cargo\registry\src\github.com-1ecc6299db9ec823\net2-0.2.33\src\socket.rs:23:5
|
23 | use sys::c;
| ^^^ maybe a missing crate sys?

error[E0432]: unresolved import sys
--> D:\cargo\registry\src\github.com-1ecc6299db9ec823\net2-0.2.33\src\ext.rs:19:5
|
19 | use sys;
| ^^^ no sys in the root

error[E0432]: unresolved import sys
--> D:\cargo\registry\src\github.com-1ecc6299db9ec823\net2-0.2.33\src\ext.rs:20:5
|
20 | use sys::c;
| ^^^ maybe a missing crate sys?

error[E0412]: cannot find type c_uint in this scope
--> D:\cargo\registry\src\github.com-1ecc6299db9ec823\net2-0.2.33\src\ext.rs:1335:39
|
1335 | fn to_ipv6mr_interface(value: u32) -> c_uint {
| ^^^^^^ not found in this scope
help: possible candidate is found in another module, you can import it into scope
|
13 | use std::os::raw::c_uint;
error[E0599]: no method named as_sock found for type &udp::UdpBuilder in the current scope

... omit similar error --> D:\cargo\registry\src\github.com-1ecc6299db9ec823\net2-0.2.33\src\ext.rs:1499:22 | 1499 | get_opt(self.as_sock(), SOL_SOCKET, SO_ERROR).map(int2err) | ^^^^^^^ method not found in &udp::UdpBuilder | = help: items from traits can only be used if the trait is implemented and in scope = note: the following trait defines an item as_sock, perhaps you need to implement it: candidate #1: ext::AsSock

error: aborting due to 317 previous errors

Some errors have detailed explanations: E0046, E0412, E0422, E0425, E0432, E0599.
For more information about an error, try rustc --explain E0046.
error: could not compile net2.
warning: build failed, waiting for other jobs to finish...
error: build failed
Error: Compiling your crate to WebAssembly failed
Caused by: failed to execute cargo build: exited with exit code: 101

my environment

wasm-pack version: wasm-pack 0.8.1
rustc version: rustc 1.39.0 (4560ea788 2019-11-04)
operation system: windows10

标签: rustwasm-bindgen

解决方案



推荐阅读