wasi-sdk
wasi-sdk copied to clipboard
How to link to the symbols from libc.imports?
Hi, I write a HTTP/GET method by use some net/sys api from wasi-sdk, and build it to wasm by CMake. But When I execute the .wasm file, it output :
However, I found those functions in path /opt/wasi-sdk/share/wasi-sysroot/lib/wasm32-wasi/libc.imports. It's a ASCII file. Does anyone know how to solve this problem? Thank you very much.
What runtime are you using to try to run your binary? I looks like that runtime is not providing the necessary imports for the module. Does the runtime claim to support WASI?
Firstly, the functions that start with __cxa_ should be implemented by libc++/libc+-abi and should not be undefined in your final binary. Are you linking with clang++ (as opposed to clang)? I'm not sure how you were able to link your module at all as the linker should have error'ed out on these symbols. Maybe you are linking with --allow-undefined? If so I suggest you remove that flag to avoid this issue.
Secondly the was_snapshot_preview1 symbols should be provided by the runtime. The fact that they are not implies the runtime you are using does perhaps does not support wasi?
Thank you for your tips.
What runtime are you using to try to run your binary? I looks like that runtime is not providing the necessary imports for the module. Does the runtime claim to support WASI?
base WAMR and SGX Enclave.
Firstly, the functions that start with
__cxa_should be implemented by libc++/libc+-abi and should not be undefined in your final binary. Are you linking withclang++(as opposed to clang)?
gcc
Thank you for your tips.
What runtime are you using to try to run your binary? I looks like that runtime is not providing the necessary imports for the module. Does the runtime claim to support WASI?
base WAMR and SGX Enclave.
I think this is probably be bug better reported there then. Its that runtime that needs to support the wasi API, not wasi-sdk.
Firstly, the functions that start with
__cxa_should be implemented by libc++/libc+-abi and should not be undefined in your final binary. Are you linking withclang++(as opposed to clang)?gcc
wasi-sdk uses llvm tools (clang, clang++, wasm-ld) so I don't see how you could be using gcc.
Perhaps you could share the full command line use to link your application. (And make sure you tell cmake to be verbose so you can see the command lines used: https://bytefreaks.net/programming-2/make-building-with-cmake-verbose)
I'm going to close this since it seems to be a linking issue specific to WAMR.