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
41
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
90
做遊戲,從SDL開始
thekk
0
310
版本控制&Git
thekk
0
61
GC project outline slider
thekk
0
43
Other Decks in Technology
See All in Technology
Além do else! Categorizando Pokemóns com Pattern Matching no JavaScript
wmsbill
0
710
今日からできる!簡単 .NET 高速化 Tips -2024 edition-
xin9le
7
3.9k
プロンプトエンジニアリングでがんばらない-Agentic Workflow へ-近藤憲児
kenjikondobai
6
1.2k
【SORACOM UG 東海】あらゆるモノがつながる社会へ、IoT と SORACOM
soracom
PRO
1
140
require(ESM)とECMAScript仕様
uhyo
4
970
20分で完全に理解するGrafanaダッシュボード
hamadakoji
5
890
.NET Profiler in 2024.
kkamegawa
2
1.4k
Google Cloud Next '24 Recap(Cloud Run/k8s)
mokocm
0
330
障害対応をちょっとずつよくしていくための 演習の作りかた
heleeen
1
1.7k
Microsoft Intune 勉強会 第 2 回目
tamaiyutaro
2
440
家族アルバム みてねにおけるGrafana活用術 / Grafana Meetup Japan Vol.1 LT
isaoshimizu
1
1k
Building a RAG-poweredAI chat appwith Python and VS Code
pamelafox
0
160
Featured
See All Featured
What the flash - Photography Introduction
edds
64
11k
Facilitating Awesome Meetings
lara
43
5.6k
The Art of Programming - Codeland 2020
erikaheidi
43
12k
Designing for Performance
lara
601
67k
KATA
mclloyd
16
12k
Documentation Writing (for coders)
carmenintech
60
4k
Building a Modern Day E-commerce SEO Strategy
aleyda
21
6.4k
What's in a price? How to price your products and services
michaelherold
238
11k
Web development in the modern age
philhawksworth
203
10k
A Modern Web Designer's Workflow
chriscoyier
689
190k
Adopting Sorbet at Scale
ufuk
69
8.6k
Let's Do A Bunch of Simple Stuff to Make Websites Faster
chriscoyier
501
140k
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