One of my rust dependency is zip, which uses a C library to compile. When I try to compile using wasm-pack, it throws an error saying that clang cannot find the header files. I am able to compile normal .c files though.
When I search online, I learnt that I need to use wasm32-unknown-emscripten as the target. I installed the emsdk and got everything working until one final part.
When I ran the command cargo build --target wasm32-unknown-emscripten
, it says that there is an undefined main
symbol. I realised it was because my crate only has a lib.rs
file and no main
function.
Somehow, I need to set the emcc
flag to --no-entry
, and tried doing so with SET EMCC_CFLAGS=--no-entry
, which ran but did not work. I tried other methods like creating a build.rs
that contains println!("cargo:rustc-link-arg=--no-entry");
. It all didn t work... I feel that I m writing something wrong here but can t find out what, or should I be trying another way of compiling my library?