Build from source on Windows 10

WasmEdge supports Windows 10. We also provide pre-built binaries and libraries for Windows. (Those using Windows 11 can use the same instructions specified here)

You can find the details here

If you would like to develop WasmEdge on Windows 10, please follow this guide to build and test from source code.

Get Source Code

  1. git clone https://github.com/WasmEdge/WasmEdge.git
  2. cd WasmEdge

Requirements and Dependencies

WasmEdge will require LLVM 13 to build our nightly build and you may need to install these dependencies by yourself.

  • Chocolatey, we use it to install cmake, ninja, and vswhere
  • Windows SDK 19041
  • LLVM 13.0.1, you can find the pre-built files here or you can just follow the instructions/commands to download automatically.

Prepare the environment

  1. # Install the required tools
  2. choco install cmake ninja vswhere
  3. $vsPath = (vswhere -latest -property installationPath)
  4. Import-Module (Join-Path $vsPath "Common7\Tools\Microsoft.VisualStudio.DevShell.dll")
  5. Enter-VsDevShell -VsInstallPath $vsPath -SkipAutomaticLocation -DevCmdArguments "-arch=x64 -host_arch=x64 -winsdk=10.0.19041.0"
  6. # Download our pre-built LLVM 13 binary
  7. $llvm = "LLVM-13.0.1-win64.zip"
  8. curl -sLO https://github.com/WasmEdge/llvm-windows/releases/download/llvmorg-13.0.1/LLVM-13.0.1-win64.zip -o $llvm
  9. Expand-Archive -Path $llvm
  10. # Set LLVM environment
  11. $llvm_dir = "$pwd\\LLVM-13.0.1-win64\\LLVM-13.0.1-win64\\lib\\cmake\\llvm"
  12. $Env:CC = "clang-cl"
  13. $Env:CXX = "clang-cl"

If you don’t need the Ahead-of-Time runtime/compiler

If you don’t need Ahead-of-Time runtime/compiler support, then set the CMake option WASMEDGE_BUILD_AOT_RUNTIME to OFF.

  1. cmake -DCMAKE_BUILD_TYPE=Release -DWASMEDGE_BUILD_AOT_RUNTIME=OFF ..

Build WasmEdge

WasmEdge provides various tools for enabling different runtime environments for optimal performance. After the build is finished, you can find there are several wasmedge related tools:

  1. wasmedge is the general wasm runtime.
    • wasmedge executes a WASM file in the interpreter mode or a compiled WASM dll file in the ahead-of-time compilation mode.
    • To disable building all tools, set the CMake option WASMEDGE_BUILD_TOOLS to OFF.
  2. wasmedgec is the ahead-of-time WASM compiler.
    • wasmedgec compiles a general WASM file into a dll file.
    • To disable building the ahead-of-time compiler, set the CMake option WASMEDGE_BUILD_AOT_RUNTIME to OFF.
  3. libwasmedge_c.dll is the WasmEdge C API shared library.
    • libwasmedge_c.dll provides the C API for the ahead-of-time compiler and the WASM runtime.
    • The APIs related to the ahead-of-time compiler will always fail if the CMake option WASMEDGE_BUILD_AOT_RUNTIME is set to OFF.
    • To disable building the shared library, set the CMake option WASMEDGE_BUILD_SHARED_LIB to OFF.
  1. $vsPath = (vswhere -latest -property installationPath)
  2. Import-Module (Join-Path $vsPath "Common7\Tools\Microsoft.VisualStudio.DevShell.dll")
  3. Enter-VsDevShell -VsInstallPath $vsPath -SkipAutomaticLocation -DevCmdArguments "-arch=x64 -host_arch=x64 -winsdk=10.0.19041.0"
  4. cmake -Bbuild -GNinja -DCMAKE_SYSTEM_VERSION=10.0.19041.0 -DCMAKE_MSVC_RUNTIME_LIBRARY=MultiThreadedDLL "-DLLVM_DIR=$llvm_dir" -DWASMEDGE_BUILD_TESTS=ON -DWASMEDGE_BUILD_PACKAGE="ZIP" .
  5. cmake --build build

If you encounter any issues in building, please check the issues section of the repository for help.

Run built-in tests

The following built-in tests are available only when the build flag WASMEDGE_BUILD_TESTS was set to ON.

Users can use these tests to verify the correctness of WasmEdge binaries.

  1. $vsPath = (vswhere -latest -property installationPath)
  2. Import-Module (Join-Path $vsPath "Common7\Tools\Microsoft.VisualStudio.DevShell.dll")
  3. Enter-VsDevShell -VsInstallPath $vsPath -SkipAutomaticLocation -DevCmdArguments "-arch=x64 -host_arch=x64 -winsdk=10.0.19041.0"
  4. $Env:PATH += ";$pwd\\build\\lib\\api"
  5. cd build
  6. ctest --output-on-failure
  7. cd -

Run applications

Next, you can follow this guide to run WebAssembly bytecode programs in wasmedge.