WebAssembly环境搭建
Environment:Ubuntu 16.06 + emscripten
URL: https://emscripten.org/docs/getting_started/downloads.html#linux
1. Installation emsdk
# Get the emsdk repo
git clone https://github.com/emscripten-core/emsdk.git # Enter that directory
cd emsdk # Fetch the latest version of the emsdk (not needed the first time you clone)
git pull # Download and install the latest SDK tools.
./emsdk install latest # Make the "latest" SDK "active" for the current user. (writes .emscripten file)
./emsdk activate latest # Activate PATH and other environment variables in the current terminal
source ./emsdk_env.sh
2. Emsdk install targets
./emsdk install 1.38.45
3. Updating the SDK
# Fetch the latest registry of available tools.
./emsdk update # Download and install the latest SDK tools.
./emsdk install latest # Set up the compiler configuration to point to the "latest" SDK.
./emsdk activate latest # Activate PATH and other environment variables in the current terminal
source ./emsdk_env.sh
4. windows /cenos 7部署流程:
下载代码
git clone https://github.com/emscripten-core/emsdk.git
cd emsdk
安装依赖,添加环境变量
# 安装依赖项,这个过程比较长,会下载并自动安装node、Java、python等环境包,耐心等待
emsdk install latest //centos 环境: ./emsdk install latest
# 激活上一步下载的环境变量临时,一旦关闭cmd窗口,环境变量就失效了。
emsdk activate latest //centos 环境: ./emsdk activate latest # 把emsdk加到环境变量中,方便后续执行命令
emsdk_env.bat //centos 环境: source ./emsdk_env.sh
编译代码
#include <stdio.h>
int main() {
printf("hello world.");
return 0;
}
编译为js
emcc test.c
执行后,会在当前cmd所在目录下生成a.out.js 和 a.out.wasm
编译为html格式的demo文件
emcc test.c -s WASM=1 -o test.html
编译后产生如下文件:

将html文件发布到web容器中,或者使用下面命令发布(本文使用httpd)
python -m http.server
# 也可以使用下面的命令,直接打开默认浏览器运行
emrun test.html
本地浏览器访问http://192.168.1.126/test.html 显示如下:

WebAssembly环境搭建的更多相关文章
- qt for webassembly环境搭建图文教程
一.前言 从Qt5.14开始,官方的在线安装提供了qt for webassembly构建套件,这对很多小白来说绝对是个好消息,也绝对是个好东西,好消息是不用再去交叉编译自己生成qt for weba ...
- .NET Core系列 : 1、.NET Core 环境搭建和命令行CLI入门
2016年6月27日.NET Core & ASP.NET Core 1.0在Redhat峰会上正式发布,社区里涌现了很多文章,我也计划写个系列文章,原因是.NET Core的入门门槛相当高, ...
- Azure Service Fabric 开发环境搭建
微服务体系结构是一种将服务器应用程序构建为一组小型服务的方法,每个服务都按自己的进程运行,并通过 HTTP 和 WebSocket 等协议相互通信.每个微服务都在特定的界定上下文(每服务)中实现特定的 ...
- rnandroid环境搭建
react-native 环境搭建具体步骤这个大家已经玩烂了,这个主要是记录下来自己做win7系统遇到的坑 1.com.android.ddmlib.installexception 遇到这个问题,在 ...
- python开发环境搭建
虽然网上有很多python开发环境搭建的文章,不过重复造轮子还是要的,记录一下过程,方便自己以后配置,也方便正在学习中的同事配置他们的环境. 1.准备好安装包 1)上python官网下载python运 ...
- springMVC初探--环境搭建和第一个HelloWorld简单项目
注:此篇为学习springMVC时,做的笔记整理. MVC框架要做哪些事情? a,将url映射到java类,或者java类的方法上 b,封装用户提交的数据 c,处理请求->调用相关的业务处理—& ...
- 【定有惊喜】android程序员如何做自己的API接口?php与android的良好交互(附环境搭建),让前端数据动起来~
一.写在前面 web开发有前端和后端之分,其实android还是有前端和后端之分.android开发就相当于手机app的前端,一般都是php+android或者jsp+android开发.androi ...
- Nexus(一)环境搭建
昨天,成功搭建了自己的 Maven 环境(详见:Maven(一)环境搭建),今天就来研究和探讨下 Nexus 的搭建! 使用背景: 安装环境:Windows 10 -64位 JDK版本:1.7 Mav ...
- 「译」JUnit 5 系列:环境搭建
原文地址:http://blog.codefx.org/libraries/junit-5-setup/ 原文日期:15, Feb, 2016 译文首发:Linesh 的博客:环境搭建 我的 Gith ...
随机推荐
- 【LeetCode】402. Remove K Digits 解题报告(Python)
[LeetCode]402. Remove K Digits 解题报告(Python) 标签(空格分隔): LeetCode 作者: 负雪明烛 id: fuxuemingzhu 个人博客: http: ...
- P1629八
P1629八 Accepted 标签:[显示标签] 描述 八是个很有趣的数字啊.八=发,八八=爸爸,88=拜拜.当然最有趣的还是8用二进制表示是1000.怎么样,有趣吧.当然题目和这些都没有关 ...
- 关于python常用的命令
os模块: os.system os.system("cat/cmd等...") os.popen print os.popen("adb shell ls ../aa. ...
- Atcoder ABC137D:Summer Vacation(贪心)
D - Summer Vacation Time Limit: 2 sec / Memory Limit: 1024 MB Score : 400 points Problem Statement T ...
- Java生成随机数的4种方式
Random Random 类诞生于 JDK 1.0,它产生的随机数是伪随机数,也就是有规则的随机数.Random 使用的随机算法为 linear congruential pseudorandom ...
- OverFeat:Integrated Recognition, Localization and Detection using Convolutional Networks
目录 概 主要内容 Sermanet P., Eigen D., Zhang X., Mathieu M., Fergus R., LeCun Y. OverFeat:integrated recog ...
- Java程序设计基础笔记 • 【第4章 条件结构】
全部章节 >>>> 本章目录 4.1 条件结构 4.1.1 程序流程控制 4.1.2 单分支if结构 4.1.3 双分支if结构 4.1.4 实践练习 4.2 多重条件结 ...
- HTML网页设计中 link 和 @import 的区别
页面中使用CSS的方式主要有3种:行内添加定义style属性值,页面头部内嵌调用和外面链接调用,其中外面引用有两种:link和@import.外部引用CSS两种方式link和@import的方式分别是 ...
- SpringBoot集成MyBatis-Plus代码生成器(Dao)
1.说明 本文基于SpringBoot集成MyBatis-Plus代码生成器, 把原来生成Entity.Mapper.Mapper XML.Service.Controller等各个模块的代码, 修改 ...
- Pytest_常用执行参数详解(3)
前面讲了测试用例的执行方式,也认识了 -v -s 这些参数,那么还有没有其它参数呢?答案肯定是有的,我们可以通过 pytest -h来查看所有可用参数. 从图中可以看出,pytest的参数有很多,但 ...