email sol follow sol wishlist Sol::Tutorials

Emscripten tutorial

Welcome

Apart from being perfectly cromulent word, Emscripten is an emerging technology that lets you compile C programs into JavaScript. It also has built-in support for SDL, so pretty much any SDL-based application (like a game) can be ported into a web page using Emscripten.

Which is, of course, completely insane idea.

But in a kind of cool way.

(If you don't see the scroller above, you're probably using a browser that doesn't work with Emscripten for some reason. The code above should work, in various performance levels, on at least recent versions of Firefox, Chrome, Safari and, yes, Internet Explorer)

Basically the javascript engine performance has improved so much that execution is only 2-4 times slower than through pure native code, and the engines keep improving. And then there's initiatives such as asm.js which aim to make tools such as Emscripten more efficient.

If you're like me, you might want to experiment on Emscripten. And if you're like me, you'd rather work on Windows. Since I went through the trouble of figuring out how to go about it, I thought I might write a tutorial about it.

First step of running Emscripten on Windows in a practical way ... is to install Linux. Yes, I know, there are instructions on how to install it on Windows, but trust me, installing Linux on a virtual box is way less hassle than to install everything Emscripten needs on Windows.

The thing is, Emscripten is actually a hodgepodge of technologies including Python, JavaScript (through node.js), Java (for some optimizations), LLVM and Clang. And probably bunch of other things that come for free on Linux, but require cygwin on Windows.

For the record, I, as well as couple other people, have tried the Windows install, only to find that something is broken (and the broken things were different among us). As Linux is the primary (or well, probably only) development environment the Emscripten authors use, it's less likely to be broken there.

Good news is, setting up virtual box Linux is less work than you'd expect, and as a bonus, you get a virtual linux box you can use for other things, like porting stuff to Linux, along with hardware OpenGL support.

As a disclaimer, like with any step-by-step tutorial, this one tries to be as accurate as possible, and probably is at the time of this writing, but reality has a tendency of changing. Especially with emerging technologies.

Finally, as a warning, you'll be downloading a lot of stuff during this tutorial, so be patient.

 

Not scared? Next we'll set up Virtualbox..

Or, if you're lucky enough to already have Linux in some form, jump straight to installing Emscripten.

If you have Emscripten installed, you can hop to Emscripten framework

As usual, feedback is appreciated.

Site design & Copyright © 2014 Jari Komppa
Possibly modified around: April 08 2013