Closed Sandesh-verma closed 2 months ago
/opt/wasi-sdk/bin/clang++ -O3 -z stack-size=4096 -Wl,--initial-memory=65536 -o test.wasm main.cpp -Wl,--export=main -Wl,--export=__main_argc_argv -Wl,--export=__data_end -Wl,--export=__heap_base -Wl,--no-entry -Wl,--allow-undefined -fno-exceptions -nostdlib
start from something simpler, like:
/opt/wasi-sdk/bin/clang++ -O3 -fno-exceptions -o test.wasm main.cpp
closing the issue as the thread is being discussed in WAMR#3690
For anyone else that arrives here looking for answers, the problem here is that you are linking with -nostdlib
which means that C++ standard library is not being includes, and hence all the undefined C++ symbols such as _ZNSt3__28ios_base5clearEj
.
In general you should also avoid --allow-undefined
since it delayes these issues until run time, when they are better solved at link time.
I have a simple hello world program for C++. Then i created a .wasm file for the same using the below command
/opt/wasi-sdk/bin/clang++ -O3 -z stack-size=4096 -Wl,--initial-memory=65536 -o test.wasm main.cpp -Wl,--export=main -Wl,--export=__main_argc_argv -Wl,--export=__data_end -Wl,--export=__heap_base -Wl,--no-entry -Wl,--allow-undefined -fno-exceptions -nostdlib
On trying to execute the generated test.wasm, using WAMR/Wasmedge, I get the below errors..
Am I missing anything here when creating the wasm module?