Error: wasmtime._error.WasmtimeError: unknown import: env::invoke_viii
has not been defined
#5083
Answered
by
xdoardo
paulocoutinhox
asked this question in
General
-
Hi, Can anyone help me here: When i call my lib
Python code: def run_task_test_wasmtime():
import wasmtime
from wasmtime import Engine, Func, Instance, Linker, Module, Store
from wasmtime.loader import WasiConfig
l.colored("Testing with wasmtime...", l.YELLOW)
current_dir = f.current_dir()
for target in c.targets_wasm:
# paths
relative_dir = os.path.join(
"build",
target["target_os"],
target["target_cpu"],
)
root_dir = os.path.join(current_dir, relative_dir)
gen_dir = os.path.join(root_dir, "gen")
gen_out_dir = os.path.join(gen_dir, "out")
wasm_file = os.path.join(gen_out_dir, "pdfium.std.wasm")
# create the engine and store
engine = Engine()
store = Store(engine)
# load the WebAssembly module
module = Module.from_file(engine, wasm_file)
# create a linker to provide the necessary imports
linker = Linker(engine)
# WASI support using wasmtime.loader.WasiConfig
wasi_config = WasiConfig()
wasi_config.inherit_stdin()
wasi_config.inherit_stdout()
wasi_config.inherit_stderr()
store.set_wasi(wasi_config)
# instantiate the WebAssembly module with linker
instance = linker.instantiate(store, module)
# now we can invoke exported functions from the WebAssembly module
try:
init_library = instance.exports(store)["FPDF_InitLibrary"]
init_library(store)
l.i("FPDF_InitLibrary successfully called.")
except KeyError:
l.e("Function 'FPDF_InitLibrary' not found.")
# invoke 'FPDF_GetLastError'
try:
get_last_error = instance.exports(store)["FPDF_GetLastError"]
result = get_last_error(store)
l.i(f"Result from FPDF_GetLastError: {result}")
except KeyError:
l.e("Function 'FPDF_GetLastError' not found.")
l.i(f"Result: {result}")
l.ok() Thanks. |
Beta Was this translation helpful? Give feedback.
Answered by
xdoardo
Sep 26, 2024
Replies: 1 comment
-
Thanks for the post! It seems you're using emscripten. Wasmtime does not support it currently, while wasmer does at least in part. Interesting endeavour, nonetheless. I think it should be possible to compile it using WASIX, let us know if you need any help! |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
syrusakbary
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks for the post! It seems you're using emscripten. Wasmtime does not support it currently, while wasmer does at least in part. Interesting endeavour, nonetheless. I think it should be possible to compile it using WASIX, let us know if you need any help!