博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Web Assembly C++ (1) : helloworld
阅读量:2432 次
发布时间:2019-05-10

本文共 1227 字,大约阅读时间需要 4 分钟。

环境部署

确保python版本至少是2.7以上的(ubuntu 18默认的是python3,理论上可以,我测试的也可以)

# Get the emsdk repogit clone https://github.com/emscripten-core/emsdk.git# Enter that directorycd emsdk# Download and install the VERSION SDK tools.# 可以安装一个最新版,也可以指定版本,为了后续的维护,建议指定版本#./emsdk install latest./emsdk install 1.38.45# Make the "latest" SDK "active" for the current user. (writes ~/.emscripten file)./emsdk activate 1.38.45# Activate PATH and other environment variables in the current terminalsource ./emsdk_env.sh# Get a specific version using the upstream backend.#./emsdk install latest-upstream# Get a specific version using the fastcomp backend.#./emsdk install 1.38.45-fastcomp# Install CMake (optional, only needed for tests and building Binaryen)sudo apt-get install cmakesudo apt-get install python2.7# Install Java (optional, only needed for Closure Compiler minification)sudo apt-get install default-jre

Hello World

hello.c

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

可能遇到的问题:

ModuleNotFoundError: No module named ‘distutils.spawn’
需要 python3-distutils

sudo apt-get install python3-distutils
emrun --no_browser --port 8080 .

或者使用python的

python -m http.server 8000

在这里插入图片描述

转载地址:http://umvmb.baihongyu.com/

你可能感兴趣的文章
GUN C中__attribute__作用
查看>>
3、系统调用之SYSCALL_DEFINE分析
查看>>
linux的signal_pending及signal
查看>>
OBJDUMP用法
查看>>
c/cplusplus通用makefile
查看>>
JavaScript-密码强度
查看>>
【SSH】1366-InCorrect string value:'\xE9\x99\x88\xE6\x96\xB0...'for column 'name' at row 1
查看>>
SpringCloud前身之微服务
查看>>
纵览全局——SSH
查看>>
纵览全局——Mybatis
查看>>
PC端-中文转拼音后续问题
查看>>
第七章-面向对象技术
查看>>
Mybatis-略识之无
查看>>
ionic 前端 - 汉字转拼音
查看>>
Ionic-与时间有关的故事-localecompare()
查看>>
ionic -- 实现根据拼音字母搜索人员
查看>>
Logback-spring.xml日志配置
查看>>
[Vue warn]: Property or method "name" is not defined on the instance but referenced during render
查看>>
ts:json串转换成数组
查看>>
String、StringBuffer和StringBuilder的区别
查看>>