最近一直在捣鼓webassembly 的东西,趁着还有个印象,赶紧记下来。
老规矩,上官网,https://emscripten.org/,按照官网教程一步步来(强烈建议挂代理)。
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
On Windows, run emsdk instead of ./emsdk, and emsdk_env.bat instead of source ./emsdk_env.sh.
可以安装指定版本,安装完成后,一定要调用emsdk activate,不然会出现emcc 无法识别等问题,同一个目录可以同时存在多个版本,使用时调用emsdk activate + 指定版本号就行。
./emsdk install 1.38.45
./emsdk activate 1.38.45
使用前调用一下source emsdk_env.sh,激活环境变量,测试是否安装成功
emcc -v
最后,Webassembly 是一项有趣的技术,它可以将C/C++ 代码编译成字节码,供js端调用,从而达到代码复用的目的。
这篇博客介绍了如何入门WebAssembly,通过访问Emscripten官网并按照步骤下载、安装及激活SDK工具。博主强调了在安装完成后激活环境变量的重要性,并提到WebAssembly能将C/C++代码编译为字节码,供JavaScript调用,实现代码复用。
744

被折叠的 条评论
为什么被折叠?



