Skip to content

Webassembly (Wasm) Supported? #39

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
shybyte opened this issue Dec 28, 2019 · 6 comments
Open

Webassembly (Wasm) Supported? #39

shybyte opened this issue Dec 28, 2019 · 6 comments

Comments

@shybyte
Copy link

shybyte commented Dec 28, 2019

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

@Dacode45
Copy link
Collaborator

Dacode45 commented Jan 7, 2020

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

@shybyte
Copy link
Author

shybyte commented Jan 7, 2020

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

@PonasKovas
Copy link

I can't compile too

@mhcerri
Copy link

mhcerri commented May 29, 2023

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

@IoIxD
Copy link
Contributor

IoIxD commented Jan 11, 2024

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
Copy link
Contributor

IoIxD commented Jan 31, 2024

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants