rustwasm / wasm-pack

📦✨ your favorite rust -> wasm workflow tool!
https://rustwasm.github.io/wasm-pack/
Apache License 2.0
6.27k stars 409 forks source link

how to use wasm-pack with c library? #1067

Open prehonor opened 3 years ago

prehonor commented 3 years ago

This is my example : https://github.com/prehonor/rust-exp01

“cd wasm” and “wasm-pack build --target web --out-name wasm --out-dir ./static” I got this error: [INFO]: Checking for the Wasm target... [INFO]: Compiling to Wasm... Compiling clib v0.1.0 (/gh/prehonor/CProject/bookmarks/baselib) error: failed to run custom build command for clib v0.1.0 (/gh/prehonor/CProject/bookmarks/baselib)

Caused by: process didn't exit successfully: /gh/prehonor/CProject/bookmarks/target/release/build/clib-158df3ebfceecbb5/build-script-build (exit status: 101) --- stdout cargo:rustc-link-search=native=/gh/prehonor/CProject/bookmarks/baselib/cglib cargo:rustc-link-lib=static=bookmarks

--- stderr /nix/store/q141hd8jl7in5223jmf7kmx9h517km4p-glibc-2.32-54-dev/include/gnu/stubs.h:7:11: fatal error: 'gnu/stubs-32.h' file not found /nix/store/q141hd8jl7in5223jmf7kmx9h517km4p-glibc-2.32-54-dev/include/gnu/stubs.h:7:11: fatal error: 'gnu/stubs-32.h' file not found, err: true thread 'main' panicked at 'called Result::unwrap() on an Err value: ()', baselib/build.rs:20:21 stack backtrace: 0: rust_begin_unwind at /rustc/c8dfcfe046a7680554bf4eb612bad840e7631c4b/library/std/src/panicking.rs:515:5 1: core::panicking::panic_fmt at /rustc/c8dfcfe046a7680554bf4eb612bad840e7631c4b/library/core/src/panicking.rs:92:14 2: core::result::unwrap_failed at /rustc/c8dfcfe046a7680554bf4eb612bad840e7631c4b/library/core/src/result.rs:1599:5 3: core::result::Result<T,E>::unwrap 4: build_script_build::main 5: core::ops::function::FnOnce::call_once note: Some details are omitted, run with RUST_BACKTRACE=full for a verbose backtrace. Error: Compiling your crate to WebAssembly failed Caused by: failed to execute cargo build: exited with exit status: 101 full command: "cargo" "build" "--lib" "--release" "--target" "wasm32-unknown-unknown"

HcySunYang commented 2 years ago

@prehonor Did you fix this issue? I came into this too....