我们将使用 Emscripten 来转换二进制。
安装 Emscripten 的前置条件:
开始安装 Emscripten:
git clone https://github.com/juj/emsdk.git
cd emsdk
emsdk install latest
emsdk activate latest
emsdk_env
开始编写应用代码:
#include <stdio.h> int main(int argc, char ** argv) { printf("Hello World\n"); printf("Jason.wang\n"); }
emcc hello.c -s WASM=1 -o hello.html
emrun --no_browser --port 4152 hello.html --无浏览器,执行端口运行,类似部署
emrun --browser chrome hello.html -- 有浏览器,但是只是一瞬间的,刷新就是访问异常
至此第一个WebAssembly 应用运行了!
原文:https://www.cnblogs.com/zhihang/p/12162895.html