https://github.com/zonayedpca/wasm-hello-world
A Simple Hello World with Web Assembly
https://github.com/zonayedpca/wasm-hello-world
Last synced: about 2 months ago
JSON representation
A Simple Hello World with Web Assembly
- Host: GitHub
- URL: https://github.com/zonayedpca/wasm-hello-world
- Owner: zonayedpca
- Created: 2020-04-19T12:05:14.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2020-04-19T12:17:33.000Z (about 6 years ago)
- Last Synced: 2025-02-03T16:08:35.059Z (over 1 year ago)
- Language: JavaScript
- Homepage: https://zonayedpca.github.io/wasm-hello-world
- Size: 37.1 KB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
### Get the compiler(Emscripten)
Follow the instruction given in their [website](https://emscripten.org/docs/getting_started/downloads.html) and install the compiler. After completing the installation, you will be able to access the command ```emcc``` from your terminal if everything goes right.
### Write your C Program
We have included one simple Hello World program here named as ```helloworld.c```
```
#include
int main() {
printf("Hello World from C\n");
return 0;
}
```
### Compile your program using Emscripten
```
emcc helloworld.c -o helloworld
```
Once done you will be able to see two more new files called ```helloworld.js``` and ```helloworld.wasm```.
### Connect the compiled files with your Webpage
This is much more easier than you can think of. Simply, add the ```helloworld.js``` file into your ```html``` file.
```
```
### Need a server to run
If you use your file directory ```file://``` to see the html file, it won't work. You need a server which can be very made using [```http-server```](https://www.npmjs.com/package/http-server) and boom, once you open up your webpage, you will see your C program is showing output into your browser console.