$30 off During Our Annual Pro Sale. View Details »
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
50
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
330
版本控制&Git
thekk
0
70
GC project outline slider
thekk
0
59
Other Decks in Technology
See All in Technology
OCI Oracle Database Services新機能アップデート(2025/09-2025/11)
oracle4engineer
PRO
1
210
Databricks向けJupyter Kernelでデータサイエンティストの開発環境をAI-Readyにする / Data+AI World Tour Tokyo After Party
genda
1
520
Haskell を武器にして挑む競技プログラミング ─ 操作的思考から意味モデル思考へ
naoya
6
1.6k
IAMユーザーゼロの運用は果たして可能なのか
yama3133
1
460
ActiveJobUpdates
igaiga
1
130
AIの長期記憶と短期記憶の違いについてAgentCoreを例に深掘ってみた
yakumo
4
400
会社紹介資料 / Sansan Company Profile
sansan33
PRO
11
390k
非CUDAの悲哀 〜Claude Code と挑んだ image to 3D “Hunyuan3D”を EVO-X2(Ryzen AI Max+395)で動作させるチャレンジ〜
hawkymisc
2
200
Debugging Edge AI on Zephyr and Lessons Learned
iotengineer22
0
220
1人1サービス開発しているチームでのClaudeCodeの使い方
noayaoshiro
1
280
regrowth_tokyo_2025_securityagent
hiashisan
0
250
Power of Kiro : あなたの㌔はパワステ搭載ですか?
r3_yamauchi
PRO
0
170
Featured
See All Featured
Automating Front-end Workflow
addyosmani
1371
200k
10 Git Anti Patterns You Should be Aware of
lemiorhan
PRO
659
61k
Designing for Performance
lara
610
69k
The Art of Delivering Value - GDevCon NA Keynote
reverentgeek
16
1.8k
4 Signs Your Business is Dying
shpigford
186
22k
Performance Is Good for Brains [We Love Speed 2024]
tammyeverts
12
1.3k
The Hidden Cost of Media on the Web [PixelPalooza 2025]
tammyeverts
1
100
Easily Structure & Communicate Ideas using Wireframe
afnizarnur
194
17k
Improving Core Web Vitals using Speculation Rules API
sergeychernyshev
21
1.3k
Visualizing Your Data: Incorporating Mongo into Loggly Infrastructure
mongodb
48
9.8k
KATA
mclloyd
PRO
33
15k
Building Adaptive Systems
keathley
44
2.9k
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