Today, I am going to explain how to setup and write a sample program.
WebAssembly enables high performance applications on web pages. WebAssembly natively runs on browser along with HTML, CSS, JavaScript and approved by W3C (World Wide Web Consortium).
To know more about WebAssembly, go through the official webiste https://webassembly.org/
Pre-requisites
- Git
- CMake
- Host system compiler
- Windows - Visual Studio 2017 +
- Linux - GCC
- Mac - XCode
- Python 2.7.x
After downloading and installing the pre-requisites, make sure git, cmake and python are accessible in path.
Install
- Open Terminal/PowerShell with Admin rights
- Get the emsdk files
- git clone https://github.com/emscripten-core/emsdk.git
- Navigate to the downloaded folder emsdk
- cd emsdk
- Install (Note: On PowerShell execute this command, Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope LocalMachine)
- ./emsdk install latest
- Activate
- ./emsdk activate latest
Create Sample HTML file
- Create folder
- mkdir hello
- Navigate to the folder
- cd hello
- Create a file hello.c and place the following code
#includeint main(int argc, char ** argv) { printf("Hello PSR!\n");}
Convert C file to HTML
emcc hello.c -o hello.html
Run WebServer (Optional)
Run emrun webserver to serve the html pages.emrun --no_browser --port 8080 .Hope, the tutorial is useful. Happy coding.
Please send your comments and feedback to psrdotcom@gmail.com
No comments:
Post a Comment