首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >wasm-pack构建报告错误:无法编译`net2`

wasm-pack构建报告错误:无法编译`net2`
EN

Stack Overflow用户
提问于 2019-12-10 11:56:40
回答 1查看 997关注 0票数 3

我曾尝试使用rustwasm引用https://rustwasm.github.io/book/game-of-life/hello-world.html,all,它运行得很好。但是,当我将reqwest = "0.9.22"添加到Cargo.toml中,然后在项目中执行wasm-pack build命令时,编译器报告了这样一个错误:

代码语言:javascript
复制
$ 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

..。忽略类似的错误--> 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) |^在&udp::UdpBuilder中找不到方法|^帮助:只有在实现特征且在范围内时,才能使用特征中的项。注意:以下特征定义了项as_sock,也许你需要实现它: candidate #1: ext::AsSock

代码语言:javascript
复制
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

我的环境

代码语言:javascript
复制
wasm-pack version: wasm-pack 0.8.1
rustc version: rustc 1.39.0 (4560ea788 2019-11-04)
operation system: windows10
EN

回答 1

Stack Overflow用户

发布于 2019-12-31 22:25:15

我也遇到过类似的问题。多亏了csmoe on Github,我发现net2不支持目标wasm32。请参阅https://github.com/rust-lang-nursery/net2-rs/blob/eda403f03033b58560d81b821f0df822f50cde4d/src/socket.rs#L15-L16

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/59259989

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档