Skip to content
/ cpp2js Public

compiling multithreaded cpp app to webassembly and js

Notifications You must be signed in to change notification settings

dempo93/cpp2js

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Cpp2js

Cmake project to demonstrate the compilation of C++ sources to Webassembly + js

Required tools

  • Cmake: Simply download and install following the instructions here
  • Emscripten SDK: just
git clone [email protected]:emscripten-core/emsdk.git
cd emsdk
./emsdk install latest

Building the example

  • locate the Emscripten.cmake in your emsdk source folder (should be /path/to/emsdk/upstream/emscripten/cmake/Modules/Platform/Emscripten.cmake)
  • create a build folder and cd into it
cd /path/to/cpp2js
mkdir build
cd build

Compile to webassembly and js

Notice: the build will not export the main

  • build with
cmake -DCMAKE_TOOLCHAIN_FILE=<path_to>/Emscripten.cmake -DCMAKE_BUILD_TYPE=Release
cmake --build -- -j8
  • serve /path/to/cpp2js with your favorite web server

Native compilation (for debugging)

Notice: a main function is provided for ease of testing and debugging. A suitable cpp compiler (gcc, clang) is required

cmake -DCMAKE_BUILD_TYPE=Debug
cmake --build -- -j8

About

compiling multithreaded cpp app to webassembly and js

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published