diff --git a/content/wasm-languages/c-lang.md b/content/wasm-languages/c-lang.md index 4d066a168..52fdd2017 100644 --- a/content/wasm-languages/c-lang.md +++ b/content/wasm-languages/c-lang.md @@ -72,14 +72,14 @@ Since it supports the WASI specification, C can be used on the Fermyon Platform The first step is to install the WASI SDK. If you use this broadly, it may be a good idea to install it in a common location. For our example, though, we will create a project and install the SDK inside of that project. You can download the latest version from the [WASI releases page](https://github.com/WebAssembly/wasi-sdk/releases). -At the time of this writing, the latest version is `14.0`. Here's a command line example for a Mac: +At the time of this writing, the latest version is `20.0`: ```console -$ curl -O -sSL https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-14/wasi-sdk-14.0-macos.tar.gz -$ tar xf wasi-sdk-14.0-macos.tar.gz +$ curl -O -sSL https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-20/wasi-sdk-20.0-linux.tar.gz +$ tar -xzf wasi-sdk-20.0-linux.tar.gz ``` -Now we can write a simple C program using WASI. Here is the text ouf `hello.c`: +Now we can write a simple C program using WASI. Here is the text of our `hello.c` file: ```c #include @@ -94,10 +94,10 @@ int main() { To compile this, we will use the `clang` that comes with the WASI SDK. ```console -./wasi-sdk-14.0/bin/clang --sysroot wasi-sdk-14.0/share/wasi-sysroot/ hello.c -o hello.wasm +$ ./wasi-sdk-20.0/bin/clang --sysroot wasi-sdk-20.0/share/wasi-sysroot/ hello.c -o hello.wasm ``` ->> Newer versions of Clang may only need the command `clang --target=wasm32-wasi --sysroot=wasi-sdk-14.0/share/wasi-sysroot/ hello.c -o hello.wasm` +>> Newer versions of Clang may only need the command `clang --target=wasm32-wasi --sysroot=wasi-sdk-20.0/share/wasi-sysroot/ hello.c -o hello.wasm` The above should produce a file named `hello.wasm`. We can execute that with Wasmtime: @@ -167,4 +167,4 @@ Here are some great resources: - Mozilla has a tutorial on [Compiling C/C++ to Wasm with Emscripten](https://developer.mozilla.org/en-US/docs/WebAssembly/C_to_wasm) - The [yo-wasm](https://github.com/deislabs/yo-wasm) tool can help you get started faster. (Yes, we built `yo-wasm`.) - Here's an example of a [Wagi fileserver written in C](https://github.com/deislabs/wagi-fileserver-c) -- If you want to work directly with the [Wasi libc](https://github.com/WebAssembly/wasi-libc), you can do that, too. \ No newline at end of file +- If you want to work directly with the [Wasi libc](https://github.com/WebAssembly/wasi-libc), you can do that, too.