0

最近我知道了 Web 组装,并且在生锈的情况下搞砸了。最终我遇到了构建问题。我的 toml 文件看起来像这样

[package]
name = "clipboard-manager"
version = "0.1.0"
edition = "2018"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[features]
default = ["console_error_panic_hook"]

[dependencies]
x11-clipboard = "0.5.2"
wasm-bindgen = "0.2.63"
js-sys = "0.3.55"
console_error_panic_hook = { version = "0.1.6", optional = true }
#libc = "0.2.105"
# log = "0.4.14"
# x11 = "2.19.1"

[profile.release]
# Tell `rustc` to optimize for small code size.
opt-level = "s"

[lib]
crate-type = ["cdylib", "rlib"]

当我想.wasm用命令构建文件时,wasm-pack build --target web我得到一堆这样的错误

error[E0425]: cannot find function `malloc` in crate `libc`
  --> /mnt/commondisk/filip/Development/personal/clipboard-manager/target/wasm32-unknown-unknown/release/build/xcb-64883900109c6e35/out/shape.rs:98:29
   |
98 |             let raw = libc::malloc(32 as usize) as *mut xcb_shape_notify_event_t;
   |                             ^^^^^^ not found in `libc`

error[E0425]: cannot find function `malloc` in crate `libc`
   --> /mnt/commondisk/filip/Development/personal/clipboard-manager/target/wasm32-unknown-unknown/release/build/xcb-64883900109c6e35/out/xfixes.rs:238:29
    |
238 |             let raw = libc::malloc(32 as usize) as *mut xcb_xfixes_selection_notify_event_t;
    |                             ^^^^^^ not found in `libc`

error[E0425]: cannot find function `malloc` in crate `libc`
   --> /mnt/commondisk/filip/Development/personal/clipboard-manager/target/wasm32-unknown-unknown/release/build/xcb-64883900109c6e35/out/xfixes.rs:330:29
    |
330 |             let raw = libc::malloc(32 as usize) as *mut xcb_xfixes_cursor_notify_event_t;
    |                             ^^^^^^ not found in `libc`

我设法通过注释掉依赖来构建 wasm 模块x11-clipboard。我尝试使用依赖项构建此模块,x11-clipboard但在我注释掉xcb依赖项之前它也失败了。如果我添加x11板条箱,它也会失败。有一段时间我认为libc这可能是一个问题,但我没有问题构建具有这种依赖关系的模块。

有谁知道为什么某些依赖项会导致构建过程失败以及如何修复它?如果无法修复,有人可以解释我为什么吗?提前致谢!

4

0 回答 0