当前位置: 首页 > 工具软件 > Emscripten > 使用案例 >

Emscripten安装、编译及搭建实例

郎弘壮
2023-12-01

​1.安装Emscripten,可参见官网的安装过程:

Emscripten下载和安装 | Emscripten中文网


#clone the source from GitHub
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.WebAssembly实例创建及搭建

代码创建webAssembly/C++,参见:

C/C++面向WebAssembly编程简介

编译,如:emcc export1.cc -o export1.js

搭建服务器
python -m http.server

或者使用Tomcat以及Apache服务器来做位服务器。

4.  在浏览器中访问 http://localhost:8000/test.html

 类似资料: