You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am trying to build the minimal example from the readme to wasm. By default it tries to build glfw using cmake, and that doesn't seem to work properly in terms of cross-compiling:
$ cargo build --target wasm32-unknown-unknown
[..]
The C compiler
"/usr/bin/clang"
is not able to compile a simple test program.
[..]
Linking C executable cmTC_77bbe
/usr/bin/clang -ffunction-sections -fdata-sections -fPIC --target=wasm32-unknown-unknown CMakeFiles/cmTC_77bbe.dir/testCCompiler.c.o -o cmTC_77bbe
wasm-ld: error: cannot open crt1.o: No such file or directory
wasm-ld: error: unable to find library -lc
wasm-ld: error: unable to find library -lgcc
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Next I tried with default-features = false in Cargo.toml, and I get this error:
$ cargo build --target wasm32-unknown-unknown
Compiling glfw v0.43.0 (https://github.com/bjz/glfw-rs.git#5298cfc6)
error[E0308]: mismatched types
--> /home/azakai/.cargo/git/checkouts/glfw-rs-9212cdc098378853/5298cfc/src/lib.rs:2903:50
|
2903 | fn raw_window_handle<C: Context>(context: &C) -> RawWindowHandle {
| ----------------- ^^^^^^^^^^^^^^^ expected enum `RawWindowHandle`, found `()`||| implicitly returns `()` as its body has no tail or `return` expressionFor more information about this error, try `rustc --explain E0308`.error: could not compile `glfw` due to previous error
The text was updated successfully, but these errors were encountered:
I don't think you can compile rust + C bindings to wasm. there's an ABI issue and fixing it breaks backwards compatibility apparently. more info rustwasm/wasm-bindgen#2209
the patch to make glfw-rs compile on emscripten target -> #531
you can then compile it to emscripten by using default-features = false to avoid glfw-sys. instead glfw symbols are provided by emscripten itself.
emscripten is using glfw 3.2, so we will obviously miss some methods like content scale or window hint string from glfw 3.3, but atleast the rest work fine.
once the patch is merged, i think this issue can be closed.
I am trying to build the minimal example from the readme to wasm. By default it tries to build glfw using cmake, and that doesn't seem to work properly in terms of cross-compiling:
Next I tried with
default-features = false
inCargo.toml
, and I get this error:The text was updated successfully, but these errors were encountered: