English 中文(简体)
Unable to compile/build rust to wasm, when dependency uses C
原标题:

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?

问题回答

暂无回答




相关问题
Creating an alias for a variable

I have the following code in Rust (which will not compile but illustrates what I am after). For readability purposes, I would like to refer the same string with two different names so that the name of ...

Rust Visual Studio Code code completion not working

I m trying to learn Rust and installed the Rust extension for VSCode. But I m not seeing auto-completions for any syntax. I d like to call .trim() on String but I get no completion for it. I read that ...

热门标签