EmscriptenCompile your C/C++ code to javascript Actually, it's from LLVM bitcode to javascript KK – Ying Reui Liang 2015/10/XX
What is Emscripten
It's a source to source compiler bases on LLVM Compile your C/C++ code into browser runnable javascript code Averagely, it's faster than handwrite code “Asm.js”
How it work
C/C++ source | clang/clang++ | V LLVM IR code | Fastcomp (LLVM backend) | v Javascript code
em++ helloworld.cpp -c -o helloworld.bc
em++ helloworld.bc -o helloworld.html
Running in terminal Running in browser
Why
Large web applications Multi platform Performance critical library
Demonstration
Debugging
The native way Like we always do The browser way Compile your codebase with -gX (X is 1~4) Then debug them on the browser
With -g4 you could even set breakpoints on C++ source code inside browser devtool!
Porting your project
Since I don't have much experience I'll only talk a little then skip the rest of them :P
- Main loop -
- Threading -
- Files/Assets -
Porting libraries
Currently, there's mainly three ways to port a library to javascript using Emscripten
- The first one - If you're using portable C/C++, or the dependencies you use had already been ported Just compile it Like jsoncpp, which relies on C++ std libraries
Write corresponding javascript code for functions in that library Like library_sdl.js - The second one -
If the library you want to port has friendly architecture for porting Use html5.h and other headers which Emscripten provide Treat Emscripten like another platform Like part of SDL2 does - The third one -
If you want to add certain port to official repo of Emscripten... Check these out Or you can discuss with me, I just port SDL2_ttf last month :)
End?
Welcome to special round!
Let's talk a little about WebAssembly
Q&A || Thanks
References
- http://kripken.github.io/emscripten-site/index.html - https://github.com/kripken/emscripten/blob/master/docs/paper.pdf - http://asmjs.org/ - https://github.com/WebAssembly/design

Emscripten - compile your C/C++ to JavaScript