Skip to content


HOME » Build » WASM

This page describes how to build GPAC for WASM/Emscripten.

A live can be seen at

Install Emscripten SDK

Follow the instructions from the emscripten docs

As a summary:

## Get the emsdk repo
git clone

## Enter that directory
cd emsdk

## Fetch the latest version of the emsdk (not needed the first time you clone)
git pull

## Download and install the latest SDK tools.
./emsdk install latest

## Make the "latest" SDK "active" for the current user. (writes .emscripten file)
./emsdk activate latest

## Activate PATH and other environment variables in the current terminal
source ./

Build GPAC dependencies

If you already installed the emscripten SDK, it is still important to run the last two commands from the previous section to activate the SDK environment.

Then you can build the dependencies for GPAC.

## Get the code
git clone
cd deps_wasm
git submodule update --init --recursive

bash [--enable-threading]

The --enable-threading option is optional and is used to build the multi-threaded version of WASM GPAC.

Build GPAC

First make sure you have pkg-config installed (sudo apt install pkg-config).

Then we must point pkg-config to the dependencies we built in the previous section by defining an environment variable:

## if you built the unthreaded version of the deps
export PKG_CONFIG_PATH=/path/to/deps_wasm/wasm/lib/pkgconfig

## if you built the threaded version of the deps
export PKG_CONFIG_PATH=/path/to/deps_wasm/wasm_thread/lib/pkgconfig

Then we can build GPAC with emscripten:

git clone
cd gpac

##for gpac unthreaded
./configure --emscripten --disable-threads --extra-cflags='-Wno-pointer-sign -Wno-implicit-const-int-float-conversion'

##for gpac threaded
./configure --emscripten --extra-cflags='-Wno-pointer-sign -Wno-implicit-const-int-float-conversion'

make -j4

You can then find the built files in the bin/gcc/ folder.


To use WASM GPAC, you need to serve the built bin/gcc/gpac.* files through a web server (it can't be accessed as a file:// resource).

GPAC example

If you have GPAC installed, you can use the included HTTP server:

gpac httpout:port=8080:rdirs=bin/gcc

For threaded version you need to enable CORS on the server:

gpac httpout:port=8080:rdirs=bin/gcc:cors=on

Apache example

For Apache, you need to add some settings for the webserver, either in a .htaccess file, or in the apache config:

    DirectoryIndex gpac.html
    Options FollowSymLinks Indexes
    AllowOverride All

    Header set Access-Control-Allow-Origin "*"
    Header set Access-Control-Expose-Headers "*"
    Header set Cross-Origin-Embedder-Policy "require-corp"
    Header set Cross-Origin-Opener-Policy "same-origin"

    AddType application/wasm wasm
    AddType application/javascript js

You can then access the gpac.html through the web server to use GPAC WASM.


For more info, you can check how the official gpac wasm builder runs at

And you can check the official live gpac wasm build at

For issues and support, go to