I can't compile when I use this library.
[package]
name = "rust_wasm"
version = "0.1.0"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[lib]
name = "testwasi"
path = "src/lib.rs"
crate-type =["cdylib"]
[dependencies]
ffmpeg-wasi = "0"
[build]
target = "wasm32-wasi"
This is my code.
use std::ffi::CString;
use std::ffi::CStr;
use std::str;
use ffmpeg_wasi::avformat::{
av_version_info,
};
pub extern fn test() {
unsafe{
av_register_all();
let info = CStr::from_ptr(av_version_info()).to_str().unwrap().to_owned();
println!("Info: {}", info);
}
}
This is error.
error: linking with `rust-lld` failed: exit status: 1
|
= note: "rust-lld" "-flavor" "wasm" "--rsp-quoting=posix" "--export" "test" "--export=__heap_base" "--export=__data_end" "-z" "stack-size=1048576" "--stack-first" "--allow-undefined" "--fatal-warnings" "--no-demangle" "/code/media-wasm/rust_wasm/target/wasm32-wasi/debug/deps/testwasi.119yydf3g7nz2rhx.rcgu.o" "/code/media-wasm/rust_wasm/target/wasm32-wasi/debug/deps/testwasi.1e3af4th2b1gnhel.rcgu.o" "/code/media-wasm/rust_wasm/target/wasm32-wasi/debug/deps/testwasi.1oek3ig4egr8m0un.rcgu.o" "/code/media-wasm/rust_wasm/target/wasm32-wasi/debug/deps/testwasi.1rqlra1q7hrkhsto.rcgu.o" "/code/media-wasm/rust_wasm/target/wasm32-wasi/debug/deps/testwasi.1udr4718k0q8gk0e.rcgu.o" "/code/media-wasm/rust_wasm/target/wasm32-wasi/debug/deps/testwasi.1yeifx0tzdvuuw14.rcgu.o" "/code/media-wasm/rust_wasm/target/wasm32-wasi/debug/deps/testwasi.2d8gwrmngo1i1jzb.rcgu.o" "/code/media-wasm/rust_wasm/target/wasm32-wasi/debug/deps/testwasi.2ix0hrydk1toj2cr.rcgu.o" "/code/media-wasm/rust_wasm/target/wasm32-wasi/debug/deps/testwasi.2sku7kmr9a99y0x3.rcgu.o" "/code/media-wasm/rust_wasm/target/wasm32-wasi/debug/deps/testwasi.2v6d3e3zblyr6za6.rcgu.o" "/code/media-wasm/rust_wasm/target/wasm32-wasi/debug/deps/testwasi.3a7h7nbqv4lgma75.rcgu.o" "/code/media-wasm/rust_wasm/target/wasm32-wasi/debug/deps/testwasi.3afle6az3n79j6b3.rcgu.o" "/code/media-wasm/rust_wasm/target/wasm32-wasi/debug/deps/testwasi.3cfqpsfoaf4c0byx.rcgu.o" "/code/media-wasm/rust_wasm/target/wasm32-wasi/debug/deps/testwasi.3eo8hkzdeayptmj3.rcgu.o" "/code/media-wasm/rust_wasm/target/wasm32-wasi/debug/deps/testwasi.3fy3lwh64wikqv06.rcgu.o" "/code/media-wasm/rust_wasm/target/wasm32-wasi/debug/deps/testwasi.3jvid9c5o75cgpkv.rcgu.o" "/code/media-wasm/rust_wasm/target/wasm32-wasi/debug/deps/testwasi.3o4g2n3k62e2136h.rcgu.o" "/code/media-wasm/rust_wasm/target/wasm32-wasi/debug/deps/testwasi.3rg3zfvm7hy2kagr.rcgu.o" "/code/media-wasm/rust_wasm/target/wasm32-wasi/debug/deps/testwasi.3rqpfleibaby47hh.rcgu.o" "/code/media-wasm/rust_wasm/target/wasm32-wasi/debug/deps/testwasi.3xzp8uyd689y0jvc.rcgu.o" "/code/media-wasm/rust_wasm/target/wasm32-wasi/debug/deps/testwasi.3yla30jmeqkt3dc0.rcgu.o" "/code/media-wasm/rust_wasm/target/wasm32-wasi/debug/deps/testwasi.402piutxsdytp81c.rcgu.o" "/code/media-wasm/rust_wasm/target/wasm32-wasi/debug/deps/testwasi.44seho64fz573v7z.rcgu.o" "/code/media-wasm/rust_wasm/target/wasm32-wasi/debug/deps/testwasi.489mt03bfu695ap.rcgu.o" "/code/media-wasm/rust_wasm/target/wasm32-wasi/debug/deps/testwasi.48ismj07hc0og0hm.rcgu.o" "/code/media-wasm/rust_wasm/target/wasm32-wasi/debug/deps/testwasi.4iwgna1too8d697a.rcgu.o" "/code/media-wasm/rust_wasm/target/wasm32-wasi/debug/deps/testwasi.5b8lchosgvn5r1ub.rcgu.o" "/code/media-wasm/rust_wasm/target/wasm32-wasi/debug/deps/testwasi.5d8mraw0kmwi9syp.rcgu.o" "/code/media-wasm/rust_wasm/target/wasm32-wasi/debug/deps/testwasi.n1i7z4w8ldcegu6.rcgu.o" "/code/media-wasm/rust_wasm/target/wasm32-wasi/debug/deps/testwasi.n6jm90ofi899aoe.rcgu.o" "/code/media-wasm/rust_wasm/target/wasm32-wasi/debug/deps/testwasi.ord8ujz8ps3l4m8.rcgu.o" "/code/media-wasm/rust_wasm/target/wasm32-wasi/debug/deps/testwasi.27b3qtgf8bxc7tr0.rcgu.o" "-L" "/code/media-wasm/rust_wasm/target/wasm32-wasi/debug/deps" "-L" "/code/media-wasm/rust_wasm/target/debug/deps" "-L" "/code/media-wasm/rust_wasm/src/third/rust-ffmpeg-wasi/wasm-libs" "-L" "/root/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/wasm32-wasi/lib" "/code/media-wasm/rust_wasm/target/wasm32-wasi/debug/deps/libffmpeg_wasi-2b37b2550ed8ec83.rlib" "/root/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/wasm32-wasi/lib/libstd-01fcc12541b386d5.rlib" "/root/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/wasm32-wasi/lib/libpanic_abort-d871bb5d8995b7e2.rlib" "/root/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/wasm32-wasi/lib/libwasi-25ade38e4b9444cc.rlib" "/root/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/wasm32-wasi/lib/librustc_demangle-d296420d4d054f6e.rlib" "/root/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/wasm32-wasi/lib/libstd_detect-24a9a2d9a29ca001.rlib" "/root/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/wasm32-wasi/lib/libhashbrown-8171499f9fabfe22.rlib" "/root/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/wasm32-wasi/lib/libminiz_oxide-5da7227bedffaa30.rlib" "/root/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/wasm32-wasi/lib/libadler-cdc6c68a3726f24f.rlib" "/root/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/wasm32-wasi/lib/librustc_std_workspace_alloc-087645de8a9fd58d.rlib" "/root/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/wasm32-wasi/lib/libunwind-ea6af84cc2c77472.rlib" "/root/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/wasm32-wasi/lib/libcfg_if-678881514599538d.rlib" "/root/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/wasm32-wasi/lib/liblibc-71897fa43d02f337.rlib" "-l" "c" "/root/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/wasm32-wasi/lib/liballoc-9b1f59330ce56757.rlib" "/root/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/wasm32-wasi/lib/librustc_std_workspace_core-ed558c3b97e153de.rlib" "/root/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/wasm32-wasi/lib/libcore-b6d90a94f12e0d39.rlib" "/root/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/wasm32-wasi/lib/libcompiler_builtins-843a799c600942bd.rlib" "-L" "/root/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/wasm32-wasi/lib" "-L" "/root/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/wasm32-wasi/lib/self-contained" "-o" "/code/media-wasm/rust_wasm/target/wasm32-wasi/debug/deps/testwasi.wasm" "--gc-sections" "--no-entry" "-O0"
= note: rust-lld: error: function signature mismatch: __wasi_path_readlink
>>> defined as (i32, i32, i32, i32, i32, i32) -> i32 in /code/media-wasm/rust_wasm/target/wasm32-wasi/debug/deps/libffmpeg_wasi-2b37b2550ed8ec83.rlib(readlinkat.o)
>>> defined as (i32, i32, i32, i32, i32) -> i32 in /root/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/wasm32-wasi/lib/self-contained/libc.a(__wasilibc_real.o)
rust-lld: error: function signature mismatch: __wasi_path_filestat_set_times
>>> defined as (i32, i32, i32, i32, i64, i64, i32) -> i32 in /code/media-wasm/rust_wasm/target/wasm32-wasi/debug/deps/libffmpeg_wasi-2b37b2550ed8ec83.rlib(utimensat.o)
>>> defined as (i32, i32, i32, i64, i64, i32) -> i32 in /root/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/wasm32-wasi/lib/self-contained/libc.a(__wasilibc_real.o)
rust-lld: error: function signature mismatch: __wasi_path_unlink_file
>>> defined as (i32, i32, i32) -> i32 in /code/media-wasm/rust_wasm/target/wasm32-wasi/debug/deps/libffmpeg_wasi-2b37b2550ed8ec83.rlib(__wasilibc_unlinkat.o)
>>> defined as (i32, i32) -> i32 in /root/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/wasm32-wasi/lib/self-contained/libc.a(__wasilibc_real.o)
rust-lld: error: function signature mismatch: __wasi_path_link
>>> defined as (i32, i32, i32, i32, i32, i32, i32) -> i32 in /code/media-wasm/rust_wasm/target/wasm32-wasi/debug/deps/libffmpeg_wasi-2b37b2550ed8ec83.rlib(linkat.o)
>>> defined as (i32, i32, i32, i32, i32) -> i32 in /root/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/wasm32-wasi/lib/self-contained/libc.a(__wasilibc_real.o)
rust-lld: error: function signature mismatch: __wasi_path_filestat_get
>>> defined as (i32, i32, i32, i32, i32) -> i32 in /code/media-wasm/rust_wasm/target/wasm32-wasi/debug/deps/libffmpeg_wasi-2b37b2550ed8ec83.rlib(faccessat.o)
>>> defined as (i32, i32, i32, i32) -> i32 in /root/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/wasm32-wasi/lib/self-contained/libc.a(__wasilibc_real.o)
rust-lld: error: function signature mismatch: __wasi_path_rename
>>> defined as (i32, i32, i32, i32, i32, i32) -> i32 in /code/media-wasm/rust_wasm/target/wasm32-wasi/debug/deps/libffmpeg_wasi-2b37b2550ed8ec83.rlib(renameat.o)
>>> defined as (i32, i32, i32, i32) -> i32 in /root/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/wasm32-wasi/lib/self-contained/libc.a(__wasilibc_real.o)
rust-lld: error: function signature mismatch: __wasi_path_symlink
>>> defined as (i32, i32, i32, i32, i32) -> i32 in /code/media-wasm/rust_wasm/target/wasm32-wasi/debug/deps/libffmpeg_wasi-2b37b2550ed8ec83.rlib(symlinkat.o)
>>> defined as (i32, i32, i32) -> i32 in /root/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/wasm32-wasi/lib/self-contained/libc.a(__wasilibc_real.o)
rust-lld: error: function signature mismatch: __wasi_path_open
>>> defined as (i32, i32, i32, i32, i32, i64, i64, i32, i32) -> i32 in /code/media-wasm/rust_wasm/target/wasm32-wasi/debug/deps/libffmpeg_wasi-2b37b2550ed8ec83.rlib(openat.o)
>>> defined as (i32, i32, i32, i32, i64, i64, i32, i32) -> i32 in /root/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/wasm32-wasi/lib/self-contained/libc.a(__wasilibc_real.o)
rust-lld: error: function signature mismatch: __wasi_path_create_directory
>>> defined as (i32, i32, i32) -> i32 in /code/media-wasm/rust_wasm/target/wasm32-wasi/debug/deps/libffmpeg_wasi-2b37b2550ed8ec83.rlib(mkdirat.o)
>>> defined as (i32, i32) -> i32 in /root/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/wasm32-wasi/lib/self-contained/libc.a(__wasilibc_real.o)
rust-lld: error: function signature mismatch: __wasi_path_remove_directory
>>> defined as (i32, i32, i32) -> i32 in /code/media-wasm/rust_wasm/target/wasm32-wasi/debug/deps/libffmpeg_wasi-2b37b2550ed8ec83.rlib(__wasilibc_rmdirat.o)
>>> defined as (i32, i32) -> i32 in /root/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/wasm32-wasi/lib/self-contained/libc.a(__wasilibc_real.o)
warning: `rust_wasm` (lib) generated 4 warnings
error: could not compile `rust_wasm` due to previous error; 4 warnings emitted
Can you give me an example that works.
And I found that there are two key avfilter functions av_buffersrc_add_frame and av_buffersink_get_frame missing from the library.