In my previous post, I created C++ in the web browser using web assembly, in this post I will be implementing it server-side.
So, let's first install all the dependencies required.
There are 3 steps
- Compile the C++ code
- Compile C++ code to WASM Binary
- Execute it using WASM Runtime
So, lets start.
Compile the C++ code
- make the folder at any preferred location in your machine
- open your favorite code editor and write Quick Sort C++ code.
- Save the file with .cpp extension. (Quick sort code can be found here)
- complile and execute C++ code.
g++ quick-sort.cpp
followed by ./a.out
Compile C++ code to WASM Binary
It can be done using following command.
We have now converted our c++ code to web assembly code.
wasic++ quick-sort.cpp -o quick-sort.wasm
Execute it using WASM Runtime
Execute the following command to see the results.
wasmtime quick-sort.wasm
Happy Hacking :)
Top comments (0)