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
51
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
130
做遊戲,從SDL開始
thekk
0
330
版本控制&Git
thekk
0
71
GC project outline slider
thekk
0
60
Other Decks in Technology
See All in Technology
名刺メーカーDevグループ 紹介資料
sansan33
PRO
0
1k
Introduction to Sansan for Engineers / エンジニア向け会社紹介
sansan33
PRO
6
68k
2026年、サーバーレスの現在地 -「制約と戦う技術」から「当たり前の実行基盤」へ- /serverless2026
slsops
2
220
AIと新時代を切り拓く。これからのSREとメルカリIBISの挑戦
0gm
0
870
Amazon S3 Vectorsを使って資格勉強用AIエージェントを構築してみた
usanchuu
3
450
仕様書駆動AI開発の実践: Issue→Skill→PRテンプレで 再現性を作る
knishioka
2
620
Bill One 開発エンジニア 紹介資料
sansan33
PRO
4
17k
制約が導く迷わない設計 〜 信頼性と運用性を両立するマイナンバー管理システムの実践 〜
bwkw
3
920
Bedrock PolicyでAmazon Bedrock Guardrails利用を強制してみた
yuu551
0
190
顧客の言葉を、そのまま信じない勇気
yamatai1212
1
350
OCI Database Management サービス詳細
oracle4engineer
PRO
1
7.4k
Codex 5.3 と Opus 4.6 にコーポレートサイトを作らせてみた / Codex 5.3 vs Opus 4.6
ama_ch
0
120
Featured
See All Featured
30 Presentation Tips
portentint
PRO
1
210
The MySQL Ecosystem @ GitHub 2015
samlambert
251
13k
How to optimise 3,500 product descriptions for ecommerce in one day using ChatGPT
katarinadahlin
PRO
0
3.4k
Design in an AI World
tapps
0
140
How to Talk to Developers About Accessibility
jct
2
130
Making Projects Easy
brettharned
120
6.6k
The Language of Interfaces
destraynor
162
26k
Performance Is Good for Brains [We Love Speed 2024]
tammyeverts
12
1.4k
What Being in a Rock Band Can Teach Us About Real World SEO
427marketing
0
170
SEOcharity - Dark patterns in SEO and UX: How to avoid them and build a more ethical web
sarafernandez
0
120
Color Theory Basics | Prateek | Gurzu
gurzu
0
200
Reality Check: Gamification 10 Years Later
codingconduct
0
2k
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