Stream: git-wasmtime

Topic: wasmtime / issue #2401 How do I run wasmtime inside C


view this post on Zulip Wasmtime GitHub notifications bot (May 05 2022 at 16:42):

alexcrichton commented on issue #2401:

I'm going to close this since this is a pretty old issue and I believe the problems here were build-related. If there are still issues I can try to help out here or feel free to reach out on Zulip as well.

view this post on Zulip Wasmtime GitHub notifications bot (May 05 2022 at 16:42):

alexcrichton closed issue #2401:

I followed this official wasmtime tutorial on embedding wasmtime in C. https://github.com/bytecodealliance/wasmtime/blob/main/examples/hello.c

It provides commands to compile the C code with hello-world wasm embedded, but I don't know what do the two lines (cargo build --release -p wasmtime-c-api, target/release/libwasmtime.a) do? cargo build is for building a rust application, what has it to do with compiling C code, let alone there is no cargo.toml, so the cargo build itself would also fail. And this static library target/release/libwasmtime.a is also not in the wasmtime repo. https://github.com/bytecodealliance/wasmtime

cargo build --release -p wasmtime-c-api
cc examples/hello.c \
-I crates/c-api/include \
-I crates/c-api/wasm-c-api/include \

### target/release/libwasmtime.a \
-lpthread -ldl -lm \
-o hello
./hello

Without question, I cannot get this hello-world wasm in C compiled and run :(

Thank you so much!


Last updated: Nov 22 2024 at 17:03 UTC