---
title: "Using Wasix with C"
description: "Currenly, Wasix is only supported by the Wasmer runtime. So, you need to install the Wasmer runtime."
url: "https://wasix.org/docs/language-guide/c/usage/"
markdown: "https://wasix.org/docs/language-guide/c/usage.md"
---

# Using Wasix with C

> 📦
>
> Currenly, Wasix is only supported by the Wasmer runtime. So, you need to install the [Wasmer ](https://wasmer.io/) runtime.

## `wasix-libc`

`wasix-libc` is a C library that provides a subset of the POSIX API for WebAssembly. It is a fork of [wasi-libc ](https://github.com/WebAssembly/wasi-libc)

### Compiling a C program to WASIX

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

- sysroot, which you can build by making the `wasi-libc` library
- A compiler, which is available in the [`wasi-sdk`](https://github.com/WebAssembly/wasi-sdk) binary
- A linker, which is also available in the [`wasi-sdk`](https://github.com/WebAssembly/wasi-sdk) binary

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.

[wasix-libc/examples](https://github.com/wasix-org/wasix-libc/tree/main/examples)

## Running a WASIX binary

`wasmer-cli` is required to run `wasix` binaries.

```shell
$ 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 ](https://docs.wasmer.io/runtime/cli#usage)

---

[Documentation index](https://wasix.org/llms.txt) · [HTML version](https://wasix.org/docs/language-guide/c/usage/)
