raylib-rs icon indicating copy to clipboard operation
raylib-rs copied to clipboard

Webassembly (Wasm) Supported?

Open shybyte opened this issue 5 years ago • 6 comments

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

shybyte avatar Dec 28 '19 07:12 shybyte

Can you post your emscripten version and what os you are using?

Dacode45 avatar Jan 07 '20 03:01 Dacode45

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))".

shybyte avatar Jan 07 '20 06:01 shybyte

I can't compile too

PonasKovas avatar Feb 26 '20 17:02 PonasKovas

@shybyte, did you manage to fix that? Thanks!

mhcerri avatar May 29 '23 00:05 mhcerri

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"

IoIxD avatar Jan 11 '24 04:01 IoIxD

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

IoIxD avatar Jan 31 '24 17:01 IoIxD