Introducing Emscripten
About Emscripten
Emscripten Toolchain
Porting code to use Emscripten
Community
Get in touch
Report a bug
Blogs
Contribute
Open Source License
Release Notes
ChangeLog
Talks and Publications
Presentations
Papers
Books
Getting Started
Download and install
SDK Downloads
Windows
Linux and Mac OS X
Installation instructions
Windows: Installing using an NSIS installer
Windows, OSX and Linux: Installing the Portable SDK
Platform-specific notes
Verifying the installation
Updating the SDK
Uninstalling the Emscripten SDK
Archived releases
Emscripten Tutorial
First things first
Verifying Emscripten
Running Emscripten
Generating HTML
Using files
Optimizing code
Emscripten Test Suite and Benchmarks
General tips and next steps
Emscripten Test Suite
Running the whole test suite
Running a specific test
Running a bunch of random tests
Core test modes
Non-core test modes
Benchmark tests
Common tests
Debugging test failures
Getting started using Emscripten from Visual Studio
Integrating Emscripten and Visual Studio
How to build a Visual Studio solution using Emscripten
How to launch a project in a web browser from Visual Studio
Specifying project compiler settings
Porting an existing solution file to use Emscripten
Creating a new Visual Studio solution for Emscripten
Bug Reporting
Fastcomp LLVM-Backend and Clang bugs
Site and documentation bugs
FAQ
How do I compile code?
Why do I get multiple errors building basic code and the tests?
I tried something: why doesn’t it work?
Do I need to change my build system to use Emscripten?
Why is code compilation slow?
Why does my code run slowly?
Why is my compiled code big?
Why does compiling code that works on another machine gives me errors?
How can I reduce startup time?
Why does my code fail to compile with an error message about inline assembly (or
{"text":"asm"}
)?
Why does my HTML app hang?
How do I run an event loop?
Why doesn’t my SDL app work?
How do I link against system libraries like SDL, boost, etc.?
What are my options for audio playback?
How can my compiled program access files?
Why can’t my code access a file in the same directory?
How can I tell when the page is fully loaded and it is safe to call compiled functions?
Why do functions in my C/C++ source code vanish when I compile to JavaScript, and/or I get
No
functions
to
process
?
Why is the File System API is not available when I build with closure?
Why does my code break and gives odd errors when using
-O2
--closure
1
?
Why do I get
undefined
is
not
a
function
or
NAME
is
not
a
function
?
Why do I get an odd python error complaining about libcxx.bc or libcxxabi.bc?
Why does running LLVM bitcode generated by emcc through
lli
break with errors about
impure_ptr
?
Why do I get a stack size error when optimizing:
RangeError:
Maximum
call
stack
size
exceeded
or similar?
Why do I get
error:
cannot
compile
this
aggregate
va_arg
expression
yet
and it says
compiler
frontend
failed
to
generate
LLVM
bitcode,
halting
afterwards?
Why does building from source fail during linking (at 100%)?
Why do I get odd rounding errors when using float variables?
Why the weird name for the project?
Porting
Code Portability and Limitations
Portability Guidelines
Code that cannot be compiled
Code that compiles but might run slowly
API Limitations
Networking
File Systems
Application Main Loop
Other APIs
Function Pointer Issues
Asm pointer casts
Specific Browser Limitations
Emscripten Runtime Environment
Input/output
File Systems
Browser main loop
Implementing an asynchronous main loop in C/C++
Execution lifecycle
Emscripten memory representation
Connecting C++ and JavaScript
Interacting with code
Calling compiled C functions from JavaScript using ccall/cwrap
Call compiled C/C++ code “directly” from JavaScript
Calling JavaScript from C/C++
Implement a C API in JavaScript
Calling JavaScript functions as function pointers from C
Access memory from JavaScript
Affect execution behaviour
Environment variables
Binding C++ and JavaScript — WebIDL Binder and Embind
Embind
A quick example
Classes
Memory management
Value types
Advanced class concepts
Overloaded functions
Enums
Constants
Using
val
to transliterate JavaScript to C++
Built-in type conversions
Performance
WebIDL Binder
A quick example
Using C++ classes in JavaScript
Pointers, References, Value types (Ref and Value)
Const
Un-deletable classes (NoDelete)
Defining inner classes and classes inside namespaces (Prefix)
Operators
enums
Sub-classing C++ base classes in JavaScript (JSImplementation)
Pointers and comparisons
NULL
void*
WebIDL types
Test and example code
Files and File Systems
File System Overview
Emscripten file system runtime environment
Emscripten file system architecture
Packaging Files
Packaging using emcc
Packaging using the file packager tool
Changing the data file location
Valid Character Set
Monitoring file usage
Test code
Synchronous Virtual XHR Backed File System Usage
Test code
Instructions
Multimedia and Graphics
EGL Support in Emscripten
What EGL is not?
How to create a WebGL context using EGL?
Implementation status and notes
OpenGL support in Emscripten
WebGL-friendly subset of OpenGL
OpenGL ES 2.0 emulation
OpenGL emulation of older desktop and mobile versions
OpenGL extensions
Test code/examples
What if I need unsupported GL features?
Debugging
Debug information
Debug mode (EMCC_DEBUG)
Compiler settings
emcc verbose output
Manual print debugging
Disabling optimizations
Emscripten-specific issues
Memory Alignment Issues
Function Pointer Issues
Infinite loops
AutoDebugger
AutoDebugger Regression Workflow
Useful Links
Need help?
Optimizing Code
How to optimize code
Advanced compiler settings
Very large projects
Memory initialization
Trading off code size and performance
Code size
Outlining
Aggressive variable elimination
Other optimization issues
C++ exceptions
Memory Growth
Inlining
Viewing code optimization passes
Unsafe optimizations
Profiling
Troubleshooting poor performance
Compiling and Running Projects
Building Projects
Integrating with a build system
Building projects with optimizations
Building projects with debug information
Using libraries
Emscripten Ports
Adding more ports
Build system issues
Build system self-execution
Dynamic linking
Pseudo-Dynamic linking
Configure may run checks that appear to fail
Manually using emcc
Alternatives to emcc
Examples / test code
Troubleshooting
Running HTML files with emrun
Features
Quick how-to
Choosing the browser to run
Security implications
Controlling web server operation
Controlling log output
Cleaning up after the run
Running web pages in Firefox
Running web pages on an Android device
Building Emscripten from Source
Emscripten Toolchain Requirements
What you’ll need
Emscripten tools and dependencies
Compiler toolchain
Test which tools are installed
Building Emscripten from Source using the SDK
What you’ll need
Building Emscripten from the main repositories
Building Emscripten using your own fork
Manually Building Emscripten on Linux
What you’ll need
Installing required tools
Configuring Emscripten settings
Validating the environment
Manually Building Emscripten on Windows
What you’ll need
Installing required tools
Configuring Emscripten settings
Validating the environment
Manually Integrating Emscripten into Visual Studio 2010
Install the vs-tool plugin
Test the installation
Learn more
Manually Building Emscripten on Mac OS X
What you’ll need
Installing required tools
Configuring Emscripten settings
Validating the environment
LLVM Backend (“Fastcomp”)
Fastcomp overview
Getting Fastcomp
Original compiler core (deprecated)
Why did this change happen?
Are there downsides?
Features not present in Fastcomp
How to disable Fastcomp
FAQ
I see
WARNING:
Linking
two
modules
of
different
target
triples
[..]
'asmjs-unknown-emscripten'
and
'le32-unknown-nacl'
..?
Manually building Fastcomp from source
What you’ll need
Building Fastcomp
Branches
Backend code structure
Configuring Emscripten Settings when Manually Building from Source
Creating the compiler configuration file
Locating the compiler configuration file (.emscripten)
Compiler configuration file-format
Editing the compiler configuration file
Verifying the Emscripten Development Environment
Testing the environment
Sanity tests
Build a basic example
Run the full test suite
Troubleshooting
Installing missing components
Other common problems
Contributing to Emscripten
Contributing
Getting started
Next steps
Developer’s Guide
Building Emscripten from source code
Repositories and branches of interest
Submitting patches
Code reviews
Compiler overview
Emscripten Test Suite
See also
AUTHORS
API Reference
emscripten.h
Inline assembly/JavaScript
Defines
Calling JavaScript From C/C++
Function pointer types for callbacks
Functions
Browser Execution Environment
Functions
Emscripten Asynchronous File System API
Typedefs
Functions
Emscripten Asynchronous IndexedDB API
Compiling
Worker API
Typedefs
Functions
Logging utilities
Defines
Functions
Socket event registration
Callback functions
Functions
Unaligned types
Typedefs
Emterpreter-Async functions
Sleeping
Network
IndexedDB
Asyncify functions
Typedefs
Functions
html5.h
How to use this API
Registration functions
Callback functions
Functions affected by web security
Test/Example code
General types
Function result values
Keys
Defines
Struct
Callback functions
Functions
Mouse
Defines
Struct
Callback functions
Functions
Wheel
Defines
Struct
Callback functions
Functions
UI
Defines
Struct
Callback functions
Functions
Focus
Defines
Struct
Callback functions
Functions
Device orientation
Defines
Struct
Callback functions
Functions
Device motion
Defines
Struct
Callback functions
Functions
Orientation
Defines
Struct
Callback functions
Functions
Fullscreen
Defines
Struct
Callback functions
Functions
Pointerlock
Defines
Struct
Callback functions
Functions
Visibility
Defines
Struct
Callback functions
Functions
Touch
Defines
Struct
Callback functions
Functions
Gamepad
Defines
Struct
Callback functions
Functions
Battery
Defines
Struct
Callback functions
Functions
Vibration
Functions
Page unload
Defines
Callback functions
Functions
WebGL context
Defines
Struct
Callback functions
Functions
CSS
Functions
preamble.js
Calling compiled C functions from JavaScript
Accessing memory
Conversion functions — strings, pointers and arrays
Run dependencies
Stack trace
Type accessors for the memory model
File System API
Persistent data
File systems
MEMFS
NODEFS
IDBFS
Devices
Setting up standard I/O devices
File system API
File types
Paths
Module object
Creating the Module object
Affecting execution
Other methods
val.h (under-construction)
bind.h (under-construction)
How to use this API
Defines
Policies
select_overload and select_const
Functions
Value tuples
Value structs
Smart pointers
Classes
Vectors
Maps
Enums
Constants
trace.h
Usage
Compiler Interaction
Initialization and Teardown
Contexts
Frames
Annotating Allocations
Overall Memory Usage
Logging Messages
Tasks
Reporting Errors
Running the Server
Design Notes
Client / Server Design
Data Batching
Do Not Perturb The Heap
Functions
Advanced APIs
settings.js
preamble.js
Module.Runtime
Advanced File System API
Tools Reference
Emscripten SDK (emsdk)
Command line syntax
Arguments
Tools and SDK targets
SDK concepts
Emscripten Compiler Configuration File (.emscripten)
“How to” guides
How do I just get the latest SDK?
How do I use emsdk?
How do I check which versions of the SDK and tools are installed?
How do I install a tool/SDK version?
How do I remove a tool or an SDK?
How do I check for updates to the Emscripten SDK?
How do I change the currently active SDK version?
How do I install and activate old Emscripten SDKs and tools?
How do I track the latest Emscripten development with the SDK?
How do I use my own Emscripten Github fork with the SDK?
Emscripten Compiler Frontend (emcc)
Command line syntax
Arguments
Environment variables
Emscripten Windows Command Prompt (emcmdprompt.bat)
Command line syntax
About this site
Searching the site
Reporting bugs
Contributing to the site
Building the site
Installing Sphinx
Ubuntu
Site builds
SDK Builds
Build version
Writing and updating articles
Style guide
How to link to a document or heading
Recommended section/heading markup
Working in markdown
Read the docs theme
Site license
Index
Docs
Documentation
SDK
Downloads
Help
Community
Github
Github Project
Home
» Compiling and Running Projects
Compiling and Running Projects
¶
This section contains topics about building projects and running the output.
Building Projects
shows how to use
Emscripten Compiler Frontend (emcc)
as a drop in replacement for
gcc
in your existing project.
Running HTML files with emrun
explains how to use
emrun
to run generated HTML pages in a locally launched web server.