raylib-rs
raylib-rs copied to clipboard
Webassembly (Wasm) Supported?
Is compiling to Webassembly supported?
I have found the file https://github.com/deltaphc/raylib-rs/blob/master/samples/Web.toml, copied it to my own project, installed https://github.com/koute/cargo-web and executed
cargo web build.
It started compiling but stopped with the error:
/home/marco/workspace/private/ray-spike/target/wasm32-unknown-emscripten/debug/build/raylib-sys-e1aa135be1052e2a/out/raylib-2.5.0/src/core.c:3496:9: error: implicit declaration of function 'emscripten_sample_gamepad_data' is invalid in C99 [-Werror,-Wimplicit-function-declaration] if (emscripten_sample_gamepad_data() == EMSCRIPTEN_RESULT_SUCCESS) numGamepads = emscripten_get_num_gamepads(); ^ /home/marco/workspace/private/ray-spike/target/wasm32-unknown-emscripten/debug/build/raylib-sys-e1aa135be1052e2a/out/raylib-2.5.0/src/core.c:3496:9: note: did you mean 'emscripten_get_gamepad_status'? /home/marco/.local/share/cargo-web/emscripten/x86_64-unknown-linux-gnu/emscripten/system/include/emscripten/html5.h:399:26: note: 'emscripten_get_gamepad_status' declared here
Can you post your emscripten version and what os you are using?
I use Ubuntu 18.04.3 LTS and cargo-web seems to use internally "emcc (Emscripten gcc/clang-like replacement) 1.38.19 ((unknown revision))".
I can't compile too
@shybyte, did you manage to fix that? Thanks!
cargo web has been unmaintained for three years and cannot compile raylib anymore. The correct command is now EMCC_CFLAGS="-sUSE_GLFW=3 -sGL_ENABLE_GET_PROC_ADDRESS -sASYNCIFY" cargo build --release --target=wasm32-unknown-emscripten.
I made a pull request to bitten2up's Raylib 5.1.0 branch to automate the flags, when that gets merged you can just use the Cargo.toml directive below and then do cargo build --release --target=wasm32=unknown-emscripten.
[dependencies.raylib]
version = "5.0.0"
git = "https://github.com/raylib-rs/raylib-rs"
branch = "5.0.0"
UPDATE: It has been merged. It's actually been accepted into the master of that branch meaning you do not even need to upgrade to 5.0