Preface
There is an installation tutorial on the official website, but some details are not clearly explained. This article will explain each step in detail.
1. Download the emsdk package
You can use git
to pull, but the pull may fail due to timeout.
git clone https://github.com/emscripten-core/emsdk.git
So you can github
download zip
the package from . After decompression emsdk-main
, you can change the package name manually emsdk
. After decompression, you can put the package in the root directory of drive D. You can also place it anywhere else. There is no requirement. This article will introduce how to put it in the root directory of drive D. .
2. Installation
1. Enter the command in the terminal to enter the emsdk folder
Open the terminal, you can use windows + R
Enter cmd
to open, enter D:
Enter, and then enter cd emsdk
the emsdk folder.
2. Install Python
Python must be installed first. Emscripten operation depends on the Python environment, and the Python version must be greater than 3.6.
Python official website download address
After the download is complete, double-click to install and follow the steps below.
-
Choose to add environment variables automatically and then install
-
Next step
-
Select these 5, usually the first 5
-
No path length limit set
-
Enter in the terminal to confirm whether Python is installed successfully. If the version number is displayed, it means the installation is successful.
3. Enter the command to complete the configuration.
first step
Enter ./emsdk install latest
the command, if it is a windows system, enter emsdk install latest
the command. If the installation fails, reinstall it. The network may fail if the network is not good.
Step 2
Enter ./emsdk activate latest
the command, if it is a windows system, enter emsdk activate latest
the command. The error message here indicates that you need to install the Python-3.9-2-nuget-64bit version, so don't worry about it.
The third step
is to enter source ./emsdk_env.sh
the command. If it is a windows system, enter emsdk_env.bat
the command. After entering this command, you will be prompted to configure the corresponding environment variables. Remember that these environment variables must be consistent with the configuration prompted.
3. Configure environment variables
Setting up EMSDK environment (suppress these messages with EMSDK_QUIET=1)
Adding directories to PATH:
PATH += D:\emsdk
Setting environment variables:
PATH = D:\emsdk;C:\Program Files\Python311\Scripts\;C:\Program Files\Python311\;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\WINDOWS\System32\OpenSSH\;C:\Program Files\nodejs\;C:\Program Files (x86)\Tencent\微信web开发者工具\dll;;C:\Pr;gram Files\Git\cmd;C:\Program Files\Git\cmd;C:\Users\mr_zx\AppData\Local\Microsoft\WindowsApps;C:\Users\mr_zx\AppData\Roaming\npm;C:\Users\mr_zx\AppData\Local\Programs\Microsoft VS Code\bin
EMSDK = D:/emsdk
Clearing existing environment variable: EMSDK_PY
Because the version and system are inconsistent, if you enter the same command, the environment variables to be configured may not be exactly the same. You need to configure them according to the prompts after entering the command. The following pictures are for reference only.
path
The variable already exists, you just need to add it to it.
After the configuration is completed, enter emcc to test whether the configuration is successful. If "'emcc' is not an internal or external command, nor is it an operable program" is displayed, the configuration is successful.
at last
At this point Emscripten
, the installation has been successfully completed. After configuring PATH, you can call this command globally. Next, you can compile the C code into JS and wasm files.
This article only explains the installation process of Emscripten. Regarding the compilation process and how to use JS files after compilation, due to space limitations, another blog will be updated later to describe in detail.
END