To build C applications that use the Wasmer runtime as a host for guest Wasm modules, you will need a C compiler installed (
gcc, for example). Check the compiler installation instructions here.
Starting with Wasmer 1.0 all the releases ship with the required libraries and headers to use Wasmer from C and C++.
If you haven't yet, let's install Wasmer:
curl https://get.wasmer.io -sSfL | sh
Once Wasmer is installed, you can get the
$ wasmer config --pkg-configprefix=/Users/USER/.wasmerexec_prefix=/Users/USER/.wasmer/binincludedir=/Users/USER/.wasmer/includelibdir=/Users/syrus/.wasmer/libName: wasmerDescription: The Wasmer library for running WebAssemblyVersion: 2.0.0Cflags: -I/Users/USER/.wasmer/include/wasmerLibs: -L/Users/syrus/.wasmer/lib -lwasmer
Download Wasmer from Wasmer releases page. Depending on your system, you will need to download:
Once you have downloaded the framework, you can now extract its contents and set the
WASMER_DIR environment variable to the path of the wasmer directory (this will be very useful when running the examples):
# Extract the contents to a dirmkdir wasmertar -C wasmer -zxvf wasmer-*.tar.gzexport WASMER_DIR=$(pwd)/wasmer# Update LD_LIBRARY_PATH to link against the libwasmer.so in the examplesexport LD_LIBRARY_PATH=$WASMER_DIR/lib/:$LD_LIBRARY_PATH
First, you can test if
gcc is installed already by running:
If this command does not return the version, then see the following:
clang is usually installed by default. However, if it is not, you can install gcc/clang by installing xcode-select on your mac.
To install gcc on a Debian based, you will want to run the following:
sudo apt-get install build-essential
Gcc should be installable on your favorite linux distro as well. Please search for the correct command for your desired distribution.
To install gcc on Windows, you will probably want to install a GNU environment on windows. We suggest using MinGW.
gcc --version# This should output: "ATTRIBUTIONS LICENSE bin include lib"ls $WASMER_DIR
Next, let's take a look at some examples!