在Wasm-Bindgen中在Rust中使用地毯 [英] Using rug in Rust with wasm-bindgen

查看:164
本文介绍了在Wasm-Bindgen中在Rust中使用地毯的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想将地毯箱与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_charlibc::c_intlibc::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-emscriptenwasm32-wasi,这两个库在libc板条箱中都已受支持.

By definition, wasm32-unknown-unknown has no libc. If you want to use emscripten or wasi you can use wasm32-unknown-emscripten or wasm32-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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆