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
70
GC project outline slider
thekk
0
60
Other Decks in Technology
See All in Technology
SREが向き合う大規模リアーキテクチャ 〜信頼性とアジリティの両立〜
zepprix
0
390
月間数億レコードのアクセスログ基盤を無停止・低コストでAWS移行せよ!アプリケーションエンジニアのSREチャレンジ💪
miyamu
0
800
Embedded SREの終わりを設計する 「なんとなく」から計画的な自立支援へ
sansantech
PRO
3
2.1k
(金融庁共催)第4回金融データ活用チャレンジ勉強会資料
takumimukaiyama
0
120
使いにくいの壁を突破する
sansantech
PRO
1
110
学生・新卒・ジュニアから目指すSRE
hiroyaonoe
2
540
GitLab Duo Agent Platform × AGENTS.md で実現するSpec-Driven Development / GitLab Duo Agent Platform × AGENTS.md
n11sh1
0
120
Databricks Free Edition講座 データサイエンス編
taka_aki
0
290
顧客との商談議事録をみんなで読んで顧客解像度を上げよう
shibayu36
0
150
15 years with Rails and DDD (AI Edition)
andrzejkrzywda
0
170
制約が導く迷わない設計 〜 信頼性と運用性を両立するマイナンバー管理システムの実践 〜
bwkw
2
850
【インシデント入門】サイバー攻撃を受けた現場って何してるの?
shumei_ito
0
1.5k
Featured
See All Featured
Digital Projects Gone Horribly Wrong (And the UX Pros Who Still Save the Day) - Dean Schuster
uxyall
0
290
AI in Enterprises - Java and Open Source to the Rescue
ivargrimstad
0
1.1k
Exploring anti-patterns in Rails
aemeredith
2
250
Improving Core Web Vitals using Speculation Rules API
sergeychernyshev
21
1.4k
The State of eCommerce SEO: How to Win in Today's Products SERPs - #SEOweek
aleyda
2
9.5k
The Success of Rails: Ensuring Growth for the Next 100 Years
eileencodes
47
7.9k
Making Projects Easy
brettharned
120
6.6k
Fantastic passwords and where to find them - at NoRuKo
philnash
52
3.6k
The Psychology of Web Performance [Beyond Tellerrand 2023]
tammyeverts
49
3.3k
What the history of the web can teach us about the future of AI
inesmontani
PRO
1
420
How to Grow Your eCommerce with AI & Automation
katarinadahlin
PRO
0
100
Winning Ecommerce Organic Search in an AI Era - #searchnstuff2025
aleyda
0
1.8k
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