ZW007 opened 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 does the quoted two lines (cargo build --release -p wasmtime-c-api, target/release/libwasmtime.a) do? cargo build is for building a wasm 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
./helloWithout question, I cannot get this hello-world wasm in C compiled and run :(
Thank you so much!
bjorn3 commented on Issue #2401:
cargo build --release -p wasmtime-c-api
This is what compiles
target/release/libwasmtime.a
. You will have to run it from the root of your wasmtime clone. Rustc can target wasm, but by default it will compile for the host system.
ZW007 edited 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
./helloWithout question, I cannot get this hello-world wasm in C compiled and run :(
Thank you so much!
ZW007 commented on Issue #2401:
cargo build --release -p wasmtime-c-api
This is what compiles
target/release/libwasmtime.a
. You will have to run it from the root of your wasmtime clone. Rustc can target wasm, but by default it will compile for the host system.
ZW007 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
./helloWithout question, I cannot get this hello-world wasm in C compiled and run :(
Thank you so much!
ZW007 edited a comment on Issue #2401:
cargo build --release -p wasmtime-c-api
This is what compiles
target/release/libwasmtime.a
. You will have to run it from the root of your wasmtime clone. Rustc can target wasm, but by default it will compile for the host system.Thank you~! When I run cargo build --release -p wasmtime-c-api from the root of wasmtime clone, it says
error: failed to readpathtowasmtimeclone/wasmtime/crates/wasi-common/WASI/tools/witx/Cargo.toml
I dont know what to do.
ZW007 reopened 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
./helloWithout question, I cannot get this hello-world wasm in C compiled and run :(
Thank you so much!
ZW007 commented on Issue #2401:
When I run cargo build --release -p wasmtime-c-api from the root of wasmtime clone, it says
error: failed to read pathtowasmtimeclone/wasmtime/crates/wasi-common/WASI/tools/witx/Cargo.tomlI dont know what to do.
ZW007 deleted a comment on Issue #2401:
When I run cargo build --release -p wasmtime-c-api from the root of wasmtime clone, it says
error: failed to read pathtowasmtimeclone/wasmtime/crates/wasi-common/WASI/tools/witx/Cargo.tomlI dont know what to do.
ZW007 commented on Issue #2401:
cargo build --release -p wasmtime-c-api
This is what compiles
target/release/libwasmtime.a
. You will have to run it from the root of your wasmtime clone. Rustc can target wasm, but by default it will compile for the host system.Thank you~! When I run cargo build --release -p wasmtime-c-api from the root of wasmtime clone, it says
error: failed to read pathtowasmtimeclone/wasmtime/crates/wasi-common/WASI/tools/witx/Cargo.tomlI dont know what to do.
ZW007 deleted a comment on Issue #2401:
cargo build --release -p wasmtime-c-api
This is what compiles
target/release/libwasmtime.a
. You will have to run it from the root of your wasmtime clone. Rustc can target wasm, but by default it will compile for the host system.Thank you~! When I run cargo build --release -p wasmtime-c-api from the root of wasmtime clone, it says
error: failed to readpathtowasmtimeclone/wasmtime/crates/wasi-common/WASI/tools/witx/Cargo.toml
I dont know what to do.
cfallin commented on Issue #2401:
It sounds like maybe the git submodules aren't cloned? Try this:
git submodule update --init
ZW007 commented on Issue #2401:
It sounds like maybe the git submodules aren't cloned? Try this:
git submodule update --init
Hi Chris, Thank you!! I thought simply a git would work. Now I am able to run the examples except the wasi one.
https://github.com/bytecodealliance/wasmtime/blob/eb650f6fe0e1f40432e7fa8d62b2885d0e4c5467/examples/wasi/main.cThe line 40 is: FILE* file = fopen("target/wasm32-wasi/debug/wasi.wasm", "rb");
but there is no wasm32-wasi directory in my wasmtime clone. I have already cargo build --release -p wasmtime-c-api But after this command, there is only a ./release directory and a CACHEDIR.TAG file in my ./target directory.
There is still something missing in my target directory I think
bjorn3 commented on Issue #2401:
I think you will also need to run
cargo build --target wasm32-wasi --example wasi
to build just that file.
ZW007 commented on Issue #2401:
I think you will also need to run
cargo build --target wasm32-wasi --example wasi
to build just that file.Thank you! I tried this command, but there is compiling error during cargo build:
Compiling errno v0.2.7
error[E0554]:#![feature]
may not be used on the stable release channel
--> /home/zhen/.cargo/registry/src/github.com-1ecc6299db9ec823/errno-0.2.7/src/lib.rs:20:33
|
20 | #![cfg_attr(target_os = "wasi", feature(thread_local))]
| ^^^^^^^^^^^^^^^^^^^^^Compiling time v0.1.44
error: aborting due to previous errorFor more information about this error, try
rustc --explain E0554
.
error: could not compileerrno
.To learn more, run the command again with --verbose.
warning: build failed, waiting for other jobs to finish...
error: build failed
ZW007 edited a comment on Issue #2401:
I think you will also need to run
cargo build --target wasm32-wasi --example wasi
to build just that file.Thank you! I tried this command, but there is compiling error during cargo build:
Compiling errno v0.2.7
error[E0554]:#![feature]
may not be used on the stable release channel
--> /home/zhen/.cargo/registry/src/github.com-1ecc6299db9ec823/errno-0.2.7/src/lib.rs:20:33
|
20 | #![cfg_attr(target_os = "wasi", feature(thread_local))]
| ^^^^^^^^^^^^^^^^^^^^^Compiling time v0.1.44
error: aborting due to previous errorFor more information about this error, try
rustc --explain E0554
.
error: could not compileerrno
.To learn more, run the command again with --verbose.
warning: build failed, waiting for other jobs to finish...
error: build failedrustc --explain E0554 says I need nightly version. So I changed by using rustup default nightly, now I got the new error :(
error[E0463]: can't find crate for
core
|
= note: thewasm32-wasi
target may not be installederror: aborting due to previous error
For more information about this error, try
rustc --explain E0463
.
error: could not compilecfg-if
ZW007 edited a comment on Issue #2401:
I think you will also need to run
cargo build --target wasm32-wasi --example wasi
to build just that file.Thank you! I tried this command, but there is compiling error during cargo build:
Compiling errno v0.2.7
error[E0554]:#![feature]
may not be used on the stable release channel
--> /home/zhen/.cargo/registry/src/github.com-1ecc6299db9ec823/errno-0.2.7/src/lib.rs:20:33
|
20 | #![cfg_attr(target_os = "wasi", feature(thread_local))]
| ^^^^^^^^^^^^^^^^^^^^^Compiling time v0.1.44
error: aborting due to previous errorFor more information about this error, try
rustc --explain E0554
.
error: could not compileerrno
.To learn more, run the command again with --verbose.
warning: build failed, waiting for other jobs to finish...
error: build failedrustc --explain E0554 says I need nightly version. So I changed by using rustup default nightly
, now I got the new error :(
error[E0463]: can't find crate for
core
|
= note: thewasm32-wasi
target may not be installederror: aborting due to previous error
For more information about this error, try
rustc --explain E0463
.
error: could not compilecfg-if
Last updated: Nov 22 2024 at 16:03 UTC