安装Emscripten编译器(emcc)操作步骤

1、首先安装python(安装的这个python是为了跑emsdk命令)
python版本不低于2.7.12，因为emsdk是一组基于python2的脚本。python下载地址（https://www.python.org/downloads/），请一定要下载V2系列版本。如果你安装了多个版本Python，请在环境变量中将版本的安装路径放在最前面。安装好后，要配置一下环境变量(安装目录)，之后再重启电脑，最用用python --version确认是否安装成功

2、安装git工具
Git是当今最流行的版本控制软件，它包含了许多高级工具。它采用了分布式版本库的作法，不需要服务器端软件，就可以运作版本控制，使得源代码的发布和交流极其方便。
下载地址：https://git-scm.com/downloads，下载好后一路默认安装即可。安装好后，要配置一下环境变量(安装目录/cmd)，之后再重启电脑，最用用git --version确认是否安装成功

3、安装Emscripten 编译器(emcc)
3.1、克隆emsdk仓库到本地目录
	git clone https://github.com/emscripten-core/emsdk.git
3.2、进入emsdk包目录
	cd emsdk
3.3、拉取最新emsdk包(容易出错，因为国内无法访问外网)
	git pull
4.4、安装最新的sdk tools(容易出错，因为国内无法访问外网)，包括Node.js、Python、Java、LLVM等依赖包
	emsdk install latest
4.5、激活sdk tools(容易出错)
	emsdk activate latest
4.6、配置环境变量
	执行emsdk_env.bat即可
4.7、将4.6生成的环境变量配置字符串手动配置到用户环境变量中

4.8、通过emcc -v检查是否安装成功，不报错就成功了




***********************************************************************以下是安装日志**************************************************************
Microsoft Windows [版本 10.0.19045.4046]
(c) Microsoft Corporation。保留所有权利。

D:\>git clone https://github.com/emscripten-core/emsdk.git
Cloning into 'emsdk'...
fatal: unable to access 'https://github.com/emscripten-core/emsdk.git/': Failure when receiving data from the peer

D:\>git clone https://github.com/emscripten-core/emsdk.git
Cloning into 'emsdk'...
remote: Enumerating objects: 3905, done.
remote: Counting objects: 100% (68/68), done.
remote: Compressing objects: 100% (45/45), done.
remote: Total 3905 (delta 37), reused 49 (delta 21), pack-reused 3837
Receiving objects: 100% (3905/3905), 2.17 MiB | 1.99 MiB/s, done.
Resolving deltas: 100% (2567/2567), done.

D:\>cd emsdk

D:\emsdk>emsdk install latest
Resolving SDK alias 'latest' to '3.1.54'
Resolving SDK version '3.1.54' to 'sdk-releases-aa1588cd28c250a60457b5ed342557c762f416e3-64bit'
Installing SDK 'sdk-releases-aa1588cd28c250a60457b5ed342557c762f416e3-64bit'..
Installing tool 'node-16.20.0-64bit'..
Downloading: D:/emsdk/downloads/node-v16.20.0-win-x64.zip from https://storage.googleapis.com/webassembly/emscripten-releases-builds/deps/node-v16.20.0-win-x64.zip, 28623474 Bytes
Unpacking 'D:/emsdk/downloads/node-v16.20.0-win-x64.zip' to 'D:/emsdk/node/16.20.0_64bit'
Done installing tool 'node-16.20.0-64bit'.
Installing tool 'python-3.9.2-nuget-64bit'..
Downloading: D:/emsdk/downloads/python-3.9.2-4-amd64+pywin32.zip from https://storage.googleapis.com/webassembly/emscripten-releases-builds/deps/python-3.9.2-4-amd64+pywin32.zip, 14413267 Bytes
Unpacking 'D:/emsdk/downloads/python-3.9.2-4-amd64+pywin32.zip' to 'D:/emsdk/python/3.9.2-nuget_64bit'
Done installing tool 'python-3.9.2-nuget-64bit'.
Installing tool 'java-8.152-64bit'..
Downloading: D:/emsdk/downloads/portable_jre_8_update_152_64bit.zip from https://storage.googleapis.com/webassembly/emscripten-releases-builds/deps/portable_jre_8_update_152_64bit.zip, 69241499 Bytes
Unpacking 'D:/emsdk/downloads/portable_jre_8_update_152_64bit.zip' to 'D:/emsdk/java/8.152_64bit'
Done installing tool 'java-8.152-64bit'.
Installing tool 'releases-aa1588cd28c250a60457b5ed342557c762f416e3-64bit'..
Downloading: D:/emsdk/downloads/aa1588cd28c250a60457b5ed342557c762f416e3-wasm-binaries.zip from https://storage.googleapis.com/webassembly/emscripten-releases-builds/win/aa1588cd28c250a60457b5ed342557c762f416e3/wasm-binaries.zip, 459538273 Bytes
Unpacking 'D:/emsdk/downloads/aa1588cd28c250a60457b5ed342557c762f416e3-wasm-binaries.zip' to 'D:/emsdk/upstream'
Done installing tool 'releases-aa1588cd28c250a60457b5ed342557c762f416e3-64bit'.
Done installing SDK 'sdk-releases-aa1588cd28c250a60457b5ed342557c762f416e3-64bit'.


D:\emsdk>emsdk activate latest
Resolving SDK alias 'latest' to '3.1.54'
Resolving SDK version '3.1.54' to 'sdk-releases-aa1588cd28c250a60457b5ed342557c762f416e3-64bit'
Setting the following tools as active:
   node-16.20.0-64bit
   python-3.9.2-nuget-64bit
   java-8.152-64bit
   releases-aa1588cd28c250a60457b5ed342557c762f416e3-64bit

Next steps:
- Consider running `emsdk activate` with --permanent or --system
  to have emsdk settings available on startup.
Adding directories to PATH:
PATH += D:\emsdk\upstream\emscripten

Setting environment variables:
PATH = D:\emsdk\upstream\emscripten;D:\emsdk;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Windows\System32\OpenSSH\;D:\Go\bin;D:\MySQL\MySQL Server 8.0\bin;D:\Redis\;d:\Git\cmd;D:\nodejs\;C:\ProgramData\chocolatey\bin;$D:\\bin;D:\Qt\6.6.1\mingw_64\bin;D:\Qt\Tools\mingw1120_64\bin;C:\Program Files\dotnet\;d:\微信web开发者工具\dll;D:\Python27;d:\Emscripten\node\0.12.2_64bit;C:\Users\zt200\AppData\Local\Programs\Python\Python311\Scripts\;C:\Users\zt200\AppData\Local\Programs\Python\Python311\;D:\MySQL\MySQL Shell 8.0\bin\;C:\Users\zt200\AppData\Local\Microsoft\WindowsApps;C:\Users\zt200\go\bin;d:\VSCode\bin;C:\Users\zt200\AppData\Roaming\npm;D:\altera\13.1\modelsim_ase\win32aloem;
EMSDK = D:/emsdk
EMSDK_NODE = D:\emsdk\node\16.20.0_64bit\bin\node.exe
EMSDK_PYTHON = D:\emsdk\python\3.9.2-nuget_64bit\python.exe
JAVA_HOME = D:\emsdk\java\8.152_64bit
Clearing existing environment variable: EMSDK_PY
The changes made to environment variables only apply to the currently running shell instance. Use the 'emsdk_env.bat' to re-enter this environment later, or if you'd like to register this environment permanently, rerun this command with the option --permanent.

D:\emsdk>emsdk_env.bat
Setting up EMSDK environment (suppress these messages with EMSDK_QUIET=1)
Setting environment variables:
PATH = D:\emsdk;D:\emsdk\upstream\emscripten;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Windows\System32\OpenSSH\;D:\Go\bin;D:\MySQL\MySQL Server 8.0\bin;D:\Redis\;d:\Git\cmd;D:\nodejs\;C:\ProgramData\chocolatey\bin;$D:\\bin;D:\Qt\6.6.1\mingw_64\bin;D:\Qt\Tools\mingw1120_64\bin;C:\Program Files\dotnet\;d:\微信web开发者工具\dll;D:\Python27;d:\Emscripten\node\0.12.2_64bit;C:\Users\zt200\AppData\Local\Programs\Python\Python311\Scripts\;C:\Users\zt200\AppData\Local\Programs\Python\Python311\;D:\MySQL\MySQL Shell 8.0\bin\;C:\Users\zt200\AppData\Local\Microsoft\WindowsApps;C:\Users\zt200\go\bin;d:\VSCode\bin;C:\Users\zt200\AppData\Roaming\npm;D:\altera\13.1\modelsim_ase\win32aloem;
Clearing existing environment variable: EMSDK_PY

D:\emsdk>


***********************************************************************以下是emcc命令**************************************************************

1、默认编译
emcc xx.c，输出a.out.wasm以及a.out.js

2、-o选项可以指定emcc的输出文件
emcc hello.cc -o hello.js，输出hello.wasm以及hello.js两个文件

