Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Emscripten - compile your C/C++ to javascript
Search
thekk
November 03, 2015
Technology
0
47
Emscripten - compile your C/C++ to javascript
Just like magic, but in technology way.
thekk
November 03, 2015
Tweet
Share
More Decks by thekk
See All by thekk
i3 tiling window manager
thekk
0
120
做遊戲,從SDL開始
thekk
0
320
版本控制&Git
thekk
0
67
GC project outline slider
thekk
0
53
Other Decks in Technology
See All in Technology
Oracle Cloud Infrastructure:2025年6月度サービス・アップデート
oracle4engineer
PRO
2
200
Definition of Done
kawaguti
PRO
6
470
SalesforceArchitectGroupOsaka#20_CNX'25_Report
atomica7sei
0
140
Oracle Audit Vault and Database Firewall 20 概要
oracle4engineer
PRO
3
1.7k
米国国防総省のDevSecOpsライフサイクルをAWSのセキュリティサービスとOSSで実現
syoshie
2
990
Snowflake Summit 2025 データエンジニアリング関連新機能紹介 / Snowflake Summit 2025 What's New about Data Engineering
tiltmax3
0
300
Model Mondays S2E02: Model Context Protocol
nitya
0
210
[TechNight #90-1] 本当に使える?ZDMの新機能を実践検証してみた
oracle4engineer
PRO
3
160
AWS CDK 実践的アプローチ N選 / aws-cdk-practical-approaches
gotok365
6
680
~宇宙最速~2025年AWS Summit レポート
satodesu
1
1.7k
20250623 Findy Lunch LT Brown
3150
0
840
“社内”だけで完結していた私が、AWS Community Builder になるまで
nagisa53
1
340
Featured
See All Featured
Automating Front-end Workflow
addyosmani
1370
200k
Templates, Plugins, & Blocks: Oh My! Creating the theme that thinks of everything
marktimemedia
31
2.4k
A designer walks into a library…
pauljervisheath
206
24k
Faster Mobile Websites
deanohume
307
31k
Bootstrapping a Software Product
garrettdimon
PRO
307
110k
Designing for Performance
lara
609
69k
For a Future-Friendly Web
brad_frost
179
9.8k
Into the Great Unknown - MozCon
thekraken
39
1.9k
Exploring the Power of Turbo Streams & Action Cable | RailsConf2023
kevinliebholz
33
5.9k
Being A Developer After 40
akosma
90
590k
Stop Working from a Prison Cell
hatefulcrawdad
270
20k
JavaScript: Past, Present, and Future - NDC Porto 2020
reverentgeek
48
5.4k
Transcript
Emscripten Compile 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
None
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