问题
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 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 looks like a good explanation about the difference.
来源:https://stackoverflow.com/questions/62110162/using-rug-in-rust-with-wasm-bindgen