← 返回命令列表

Linux command

wasm2c 命令

文本

复制后可按需替换文件名、目录或参数。

常用示例

Convert to C

wasm2c [input.wasm] -o [output.c]

Generate header

wasm2c [input.wasm] -o [output.c] --header=[output.h]

Module name

wasm2c [input.wasm] -o [output.c] --module-name=[mymod]

说明

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.

参数

-o _FILE_
Output C file.
--header _FILE_
Generate header.
--module-name _NAME_
C module name.
--help
Show help.

FAQ

What is the wasm2c command used for?

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.

How do I run a basic wasm2c example?

Run `wasm2c [input.wasm] -o [output.c]` in a terminal, then adjust file names, paths, flags, or remote targets for your system.

What does -o _FILE_ do in wasm2c?

Output C file.