LinuxCommandLibrary
GitHubF-DroidGoogle Play Store

wasm2c

Convert WebAssembly to portable C code

TLDR

Convert to C
$ wasm2c [input.wasm] -o [output.c]
copy
Generate header
$ wasm2c [input.wasm] -o [output.c] --header=[output.h]
copy
Module name
$ wasm2c [input.wasm] -o [output.c] --module-name=[mymod]
copy

SYNOPSIS

wasm2c [-o output] [--header file] [options] input

DESCRIPTION

wasm2c is a tool from the WABT (WebAssembly Binary Toolkit) that translates WebAssembly binary modules into portable C source code. The generated C code can be compiled with any standard C compiler, enabling WebAssembly modules to run natively without a WebAssembly runtime.The tool produces both a C source file containing the translated module logic and an optional header file with function declarations and type definitions. A custom module name can be specified to control the naming of generated symbols, which is useful when linking multiple translated modules together.This approach is useful for embedding WebAssembly functionality in C/C++ projects, running WebAssembly on platforms without a runtime, or analyzing module behavior through the generated source code.

PARAMETERS

-o FILE

Output C file.
--header FILE
Generate header.
--module-name NAME
C module name.
--help
Show help.

INSTALL

sudo apt install wabt
copy
sudo dnf install wabt
copy
sudo pacman -S wabt
copy
brew install wabt
copy
nix profile install nixpkgs#wabt
copy

CAVEATS

Generated code large. Slow compilation. Part of WABT.

HISTORY

wasm2c is part of WABT (WebAssembly Binary Toolkit), converting WebAssembly to portable C code.

SEE ALSO

Braincup
Open source brain training for math, memory and focus
Braincup mini-games
41 mini-games · Apache-2.0
No ads · No tracking
Play in browser
Download Braincup on the App StoreGet Braincup on Google PlayGet Braincup on F-Droid
276 stars
From the maker of Linux Command Library
Copied to clipboard
Braincup
Open source brain training for math, memory and focus. 41 mini-games, from mental arithmetic to Sudoku, N-Back and Solo Chess.
Apache-2.0 licensed · No ads · No tracking · No account
From the maker of Linux Command Library
Download Braincup on the App StoreGet Braincup on Google PlayGet Braincup on F-Droid