Trying to get wasm/asmjs stuff compiling


going on info here

and the sample kvark recently put up,

i’m trying to compile rust for asmjs or wasm, but i’m always getting errors like this … including from the one liner in the first link

rustup target add wasm32-unknown-emscripten
info: component 'rust-std' for target 'wasm32-unknown-emscripten' is up to date

 rustc --target=wasm32-unknown-emscripten

error[E0463]: can't find crate for `std`
  = note: the `wasm32-unknown-emscripten` target may not be installed

any ideas what i might have missed… i’ve got

rustup 1.7.0 (813f7b7a8 2017-10-30)
rustc 1.24.0-nightly (f8af59d95 2017-12-13)
cargo 0.25.0-nightly (930f9d949 2017-12-05)

I’ve got the emsdk installed and have managed to compile and run a ‘hello triangle’ type example from C++ -> asmjs, and seen that running in a browser; (but haven’t tried wasm with C++ yet).

I’d be ok with either asmjs or wasm … I’m told there’s more support for asmjs (emulation of SDL etc?) but it looked like the kvark sample was proving gl/IO interfacing for Rust<-wasm->browser through more rustic libraries (am I understanding this right… ‘emscripten’ is giving you emulation of native libraries that go though JS shims to get the appropriate functionality from the browser, and writing those shims is a work in progress)

EDIT - hacking around I at least managed to convert my rough ‘hello triangle’ sample from C++ to Rust via asmjs, I can see a rust-generated triangle in the browser now.

I’d still like to be able to get the wasm example working though


According to this guide you need a +nightly in the compile command, so try

rustc +nightly --target=wasm32-unknown-emscripten


I note that i had a dumb typo, wasm-… vs wasm32; I also had confusion between different versions of rust installed on my machine in different places, and one didn’t think it had the target whilst the other did.

at the minute i’m experimenting with asmjs, which I can get working … I have some other tangents to explore and will get back to wasm