27
2018
06

windows10安装WebAssembly

WebAssembly能把c语言编译成wasm在浏览器上运行。

asm.js还只是给javascript加了类型,通过javascript虚拟机实时编译来提高性能。wasm直接就是字节码,可以理解为web端的汇编。性能肯定要高很多。

1、安装+入门教程:https://webassembly.org/getting-started/developers-guide/

2、如果是windows10,可以安装linux子系统,然后在linux里边安装,https://docs.microsoft.com/zh-cn/windows/wsl/install-win10 ,win7反正我是没有安装成功。即使不用WebAssembly,windows里边装一个linux系统也可以用来学习好多东西。

3、安装失败的话,需要开启“适用于Linux的Windows子系统”,在 控制面板->程序和功能->启用或关闭windows功能 里边。参考:https://blog.csdn.net/JayTsang/article/details/78014474

4、安装成功之后,回到,按照教程安装。


linux系统我选的ubuntu。Ubuntu下几种常用的文本编辑器

windows下,ubuntu的安装目录,我用Everything.exe搜出来的。

可以使用ln创建软链接,这样就可以把你的文件放到windows的任意目录下了。参考:https://juejin.im/entry/59352f62ac502e0068b12630

ln命令详细介绍:http://man.linuxde.net/ln

编译完成,通过html访问的时候,可能会报错:

stdio streams had content in them that was not flushed. you should set NO_EXIT_RUNTIME to 0 (see the FAQ), or make sure to emit a newline when you printf etc.

printErr @ hello.html:1249

编译的时候,加上-s NO_EXIT_RUNTIME=1就可以了。

如:emcc hello.c -s WASM=1 -s NO_EXIT_RUNTIME=0 -o hello.html

参考:https://github.com/kripken/emscripten/pull/5878/files


应该也可以通过docker来部署,windows下安装实在太痛苦了。



« 上一篇下一篇 »

发表评论:

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。