Skip to content
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

clib namespace types undefined when compiling for wasm32-unknown-unknown with wasm-pack #1022

Open
mattgreeley opened this issue Aug 28, 2020 · 2 comments

Comments

@mattgreeley
Copy link

mattgreeley commented Aug 28, 2020

Bit of a newbie here... I'm not sure if this is the best place to put this... (I will probably cross post to wasm-pack, etc.)

I am trying to build rust-sdl2 v0.34.3 targeting wasm32-unknown-unknown with wasm-pack build...

But I am getting errors while compiling sdl2-sys v0.34.2...

Specifically certain types (eg. c_char) are not found in crate libc.


mac-machinename:wasm-lib-canvas mac-username$ wasm-pack build --scope clearair43
[INFO]: 🎯  Checking for the Wasm target...
[INFO]: 🌀  Compiling to Wasm...
   Compiling version-compare v0.0.10
   Compiling libc v0.2.76
   Compiling bitflags v1.2.1
   Compiling sdl2 v0.34.3
   Compiling lazy_static v1.4.0
   Compiling sdl2-sys v0.34.2   Compiling sdl2-sys v0.34.2
error[E0412]: cannot find type `c_char` in crate `libc`
   --> /Users/mac-username/repos/wasm-lib-canvas/target/wasm32-unknown-unknown/release/build/sdl2-sys-6a1b51b03ef58e2a/out/sdl_bindings.rs:917:46
    |
917 |     pub fn SDL_GetPlatform() -> *const libc::c_char;
    |                                              ^^^^^^ not found in `libc`

error[E0412]: cannot find type `c_ulong` in crate `libc`
   --> /Users/mac-username/repos/wasm-lib-canvas/target/wasm32-unknown-unknown/release/build/sdl2-sys-6a1b51b03ef58e2a/out/sdl_bindings.rs:919:25
    |
919 | pub type size_t = libc::c_ulong;
    |                         ^^^^^^^ not found in `libc`

error[E0412]: cannot find type `c_int` in crate `libc`
   --> /Users/mac-username/repos/wasm-lib-canvas/target/wasm32-unknown-unknown/release/build/sdl2-sys-6a1b51b03ef58e2a/out/sdl_bindings.rs:920:26
    |
920 | pub type wchar_t = libc::c_int;
    |                          ^^^^^ not found in `libc`

What have I tried to solve on my own?

Found this similar issue: rust-ndarray/ndarray-linalg#121

Which links to this issue...sfackler/rust-openssl#1016 ... with these comments..

  • "For the wasm target it's still an open question how Rust and C code interoperate."
  • "for now we’d recommend using all-rust solutions (if they exist) fro the wasm32-unknown-unknown case..."
  • "To be clear this likely has a path forwar to working with the {asmjs, wasm32}-unknown-emscripten targets..."

Found this repo but it looks like it relies on emscripten

My Specific Questions...

  • Is Rust+SDL2==>WASM a non-starter today due to clib issues?
  • Is the best path to 'fall back' to emscripten?
  • Any other pointers because I am feeling pretty blocked?
@felipellrocha
Copy link

any luck here? Ran into the same issue today

@EriKWDev
Copy link

Still not resolved. Any reason libc::c_int is used over core::ffi::c_int?

I see in the build.rs for sdl-sys it is explicitly requested that libc be used

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

3 participants