emcc,wasm,webassembly

时间:2023-03-09 17:03:14
emcc,wasm,webassembly

WASM:

https://github.com/Hanks10100/wasm-examples/tree/master/simple

mkdir hello
cd hello
echo '#include <stdio.h>' > hello.c
echo 'int main(int argc, char ** argv) {' >> hello.c
echo 'printf("Hello, world!\n");' >> hello.c
echo '}' >> hello.c
emcc hello.c -s WASM=1 -o hello.html

printf '#include<iostream> \nint main() { std::cout<<"hello world"<<std::endl; return 0;}' > helloworld.cpp

docker run --rm -v $(pwd):/src trzeci/emscripten emcc helloworld.cpp -o helloworld.html

docker run --rm -v $(pwd):/src trzeci/emscripten emcc math.c -Os -s WASM=1 -s SIDE_MODULE=1 -o math.wasm

python3 -m http.server 8080 #此时打开localhost:8080即可看到相应页面

emcc math.c -Os -s WASM=1 -s SIDE_MODULE=1 -o math.wasm

https://github.com/Hanks10100/wasm-examples
https://blog.****.net/liuyan19891230/article/details/79144332
https://segmentfault.com/a/1190000008402872