1. 安装emsdk
# git clone https://github.com/juj/emsdk.git
# cd emsdk
# ./emsdk install latest
# ./emsdk activate latest
# source "/home/emsdk/emsdk_env.sh"
2. 编译
新建一个文件example.c,写入下面的代码
#include <emscripten.h>
int main()
{
EM_ASM({ alert('Hello World!'); });
}
然后进行编译
# emcc example.c -o example.html
启动http服务
# emrun --no_browser --port 8080 example.html
在浏览器输入: http://<ip>:8080/example.html
就会跳出对话框Hello World!
参考:
http://www.ruanyifeng.com/blog/2017/09/asmjs_emscripten.html
https://www.cnblogs.com/jixiaohua/p/10424941.html
https://github.com/emscripten-core/emsdk