Language Guide

Using Wasix with C


Currenly, Wasix is only supported by the Wasmer runtime. So, you need to install the Wasmer (opens in a new tab) runtime.


wasix-libc is a C library that provides a subset of the POSIX API for WebAssembly. It is a fork of wasi-libc (opens in a new tab)

Compiling a C program to WASIX

For compiling a C program to WASIX you need two things:

You also need to export three environment variables:

  • CC - the compiler to use (wasi-sdk/clang)
  • SYSROOT - the sysroot to use (wasix-libc/sysroot)
  • LLD_PATH - the linker to use (wasi-sdk/lld)

You can also build the examples from wasix-libc by running make in the examples directory. These are a good starting point for learning how to use wasix-libc. The Makefile provides a good example of how to compile a C program to WASIX.


Running a WASIX binary

wasmer-cli is required to run wasix binaries.

$ wasmer run <path-to-wasm-file>

Additional flags


Some wasm files need extra flags that can be provided while running the file with the runtime. For example, wasmer run --enable-threads --net ./target/wasix/debug/hello.wasm. Learn more about Wasmer's runtime flags (opens in a new tab)