Using rug in Rust with wasm-bindgen

偶尔善良 提交于 2020-07-10 07:44:43

问题


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

unresolved imports libc::c_char, libc::c_int, libc::c_long.

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.


回答1:


rug depends on libc

I found https://github.com/rust-lang/libc/issues/858#issuecomment-573331279

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 looks like a good explanation about the difference.



来源:https://stackoverflow.com/questions/62110162/using-rug-in-rust-with-wasm-bindgen

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!