When targeting WebAssembly, C/C++ code can be compiled as a library, and then get statically linked to a Rust project.
Install the Zig toolchain in order to compile C and C++ code to WebAssembly.
zig cc
is available for many platforms including Windows, and makes it easy to switch back and forth between native and wasm targets. WebAssembly is a Tier-1 target, and it was successfully used to port libraries such as ffmpeg
, zlib
, openssl
, boringssl
and libsodium
.