Join Matt Scarpino for an in-depth discussion in this video Installation walk-through, part of WebAssembly: Accessing C and C++ in Web Applications.
- [Instructor] To install the latest version of Emscripten, you need to obtain a package called EMSDK, which stands for the Emscripten Software Development Kit. You can download this by visiting https://github.com/juj/emsdk. Then click on the Clone or Download button and select Download ZIP. This provides an archive that contains all of the files needed to install Emscripten.
I'm going to move this to the C drive and extract it here. Then I'll rename it to EMSDK. As you can see, it has a number of files here for different operating systems. There are EMSDK scripts for Mac OS and Linux, and there's an EMSDK batch file for Windows. So I'll use this batch file to Command Prompt to install Emscripten. The first command I'll use is emsdk update, which accesses the latest registry of tools.
The next command is emsdk install sdk-incoming-64bit binaryen-master-64bit, which downloads the source files and compiles the source code to create the Emscripten utilities. At this point, EMSDK has downloaded and built all the utilities that we'll need to compile C++ code to web assembly.
You can see that there's a new directory called Emscripten, which contains a folder called Incoming. And inside this folder, you can see all the utilities that we'll be using throughout this course. Primarily, we'll be using emcc to compile C code, em++ to compile C++ code, emmake to execute commands in a Makefile, and emrun to launch browser to display the contents of our webpage.
Now that the tools have been downloaded and built, the next step is to activate them. This activation process is going to create a file called .emscripten in your Home directory. And the command for activating the tools is emsdk activate dsk-incoming-64bit binaryen-master-64bit. So let's try it again from the EMSDK directory.
To activate Emscripten's tools, I'll run the command emsdk activate SDK-incoming-64bit binaryen-master-64bit. The last step is to set Emscripten's environment variables. On Windows, you can do this using the emsdk_env.bat file. So I'll run emsdk_env.bat with the flag --global, which tells the script that I want these environment variables to apply to all users on the system.
In this video, I've demonstrated how to download EMSDK and install Emscripten's tools. Keep in mind that this may take a long time for different systems. In fact, it may take up to one or two hours. In the next video, I'll discuss EMCC, EM++ and EM-run, and I'll explain how they work together in web assembly development.
- Programming for WebAssembly with Enscripten
- Building projects with enmake
- Practical algorithms for WebAssembly apps
- Analyzing WebAssembly apps