在Wasm-Bindgen中在Rust中使用地毯 [英] Using rug in Rust with wasm-bindgen
问题描述
我想将地毯箱与wasm-bindgen一起使用,以允许我在Web浏览器中使用任意精度算术.但是,每当我尝试编译时,它都无法构建库,类似于
I'd like to use the rug crate with wasm-bindgen to allow me to use arbitrary-precision arithmetic in a web browser. Whenever I try to compile, though, it fails to build the library, saying something along the lines of
未解决的导入libc::c_char
,libc::c_int
,libc::c_long
.
是否有解决方法?如果涉及Emscripten很好,但是我希望能够主要编写Rust代码.
Is there a workaround for this? If Emscripten is involved that's fine, but I'd like to be able to mostly write Rust code.
推荐答案
rug
取决于libc
我发现 https://github.com/rust-lang/libc/issues/858#issuecomment-573331279
根据定义,
wasm32-unknown-unknown
没有libc
.如果要使用emscripten或wasi,则可以使用wasm32-unknown-emscripten
或wasm32-wasi
,这两个库在libc板条箱中都已受支持.
By definition,
wasm32-unknown-unknown
has nolibc
. If you want to use emscripten or wasi you can usewasm32-unknown-emscripten
orwasm32-wasi
, both of which are already supported in the libc crate.
https://users.rust-lang .org/t/wasm-unknown-vs-emscripten/22997/5 可以很好地说明两者之间的区别.
https://users.rust-lang.org/t/wasm-unknown-vs-emscripten/22997/5 looks like a good explanation about the difference.
这篇关于在Wasm-Bindgen中在Rust中使用地毯的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!