Skip to content

wasm-ld error when using sokol-rust as a library #14

@terrybrash

Description

@terrybrash

I'm using sokol-rust as a dependency in an application. I have the latest commit to master, as shown in my cargo.lock:

[[package]]
name = "sokol"
version = "0.1.0"
source = "git+https://github.com/floooh/sokol-rust.git#0c3ee4d0aa851f9d7a50e3bd5426d9fd95fda72d"
dependencies = [
 "cc",
]

The project compiles fine when targeting native (Windows and Mac). However, when running cargo build --target wasm32-unknown-emscripten, I get wasm-ld errors:

  = note: wasm-ld: error: C:\Users\Terry\tsrs\target\wasm32-unknown-emscripten\debug\deps\libsokol-c2aa81c2fa949025.rlib(sokol_gfx.o): undefined symbol: glClearBufferfv
          wasm-ld: error: C:\Users\Terry\tsrs\target\wasm32-unknown-emscripten\debug\deps\libsokol-c2aa81c2fa949025.rlib(sokol_gfx.o): undefined symbol: glClearBufferfi
          wasm-ld: error: C:\Users\Terry\tsrs\target\wasm32-unknown-emscripten\debug\deps\libsokol-c2aa81c2fa949025.rlib(sokol_gfx.o): undefined symbol: glClearBufferfv
          wasm-ld: error: C:\Users\Terry\tsrs\target\wasm32-unknown-emscripten\debug\deps\libsokol-c2aa81c2fa949025.rlib(sokol_gfx.o): undefined symbol: glClearBufferiv
          wasm-ld: error: C:\Users\Terry\tsrs\target\wasm32-unknown-emscripten\debug\deps\libsokol-c2aa81c2fa949025.rlib(sokol_gfx.o): undefined symbol: glReadBuffer
          wasm-ld: error: C:\Users\Terry\tsrs\target\wasm32-unknown-emscripten\debug\deps\libsokol-c2aa81c2fa949025.rlib(sokol_gfx.o): undefined symbol: glBlitFramebuffer
          wasm-ld: error: C:\Users\Terry\tsrs\target\wasm32-unknown-emscripten\debug\deps\libsokol-c2aa81c2fa949025.rlib(sokol_gfx.o): undefined symbol: glInvalidateFramebuffer
          wasm-ld: error: C:\Users\Terry\tsrs\target\wasm32-unknown-emscripten\debug\deps\libsokol-c2aa81c2fa949025.rlib(sokol_gfx.o): undefined symbol: glGetStringi
          wasm-ld: error: C:\Users\Terry\tsrs\target\wasm32-unknown-emscripten\debug\deps\libsokol-c2aa81c2fa949025.rlib(sokol_gfx.o): undefined symbol: glDeleteSamplers
          wasm-ld: error: C:\Users\Terry\tsrs\target\wasm32-unknown-emscripten\debug\deps\libsokol-c2aa81c2fa949025.rlib(sokol_gfx.o): undefined symbol: glBindSampler
          wasm-ld: error: C:\Users\Terry\tsrs\target\wasm32-unknown-emscripten\debug\deps\libsokol-c2aa81c2fa949025.rlib(sokol_gfx.o): undefined symbol: glBindSampler
          wasm-ld: error: C:\Users\Terry\tsrs\target\wasm32-unknown-emscripten\debug\deps\libsokol-c2aa81c2fa949025.rlib(sokol_gfx.o): undefined symbol: glBindSampler

Creating a build.rs in my project with the following fixes the the errors:

fn main() {
    println!("cargo:rustc-link-arg=-sUSE_WEBGL2");
}

But this was already added to sokol-rust, so I don't understand why it's required in my project as well.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions