Mach v0.3 has been released! For all the details check out the announcement

Getting Started with Mach core

Here you will learn how to use mach core in your own project/repository. If you haven’t already, check out the examples as those describe how to actually use Mach core’s APIs, this page just describes project setup.

Check you are using the specific Zig version Mach supports

Make sure you’re using the specific Zig version Mach supports - other Zig versions will not work.

Create your Zig project

mkdir myproject/
cd myproject/
zig init

Add Mach as a dependency

Add the Mach standard library to your project so you can @import("mach").

Additionally, you will need this line in your build.zig file:

@import("mach").link(mach_dep.builder, exe);

If you get error: 'dawn/webgpu.h' file not found then you forgot to add the above line.

Render a triangle

To begin your project, we suggest starting with three files to render a triangle - simply copy these into your src/ folder:

Building your project

Build / run / unit test

Build your app (executable will go into zig-out/bin/):

zig build

Build and run your app (useful while developing):

zig build run

Run unit tests:

zig build test

Cross-compile

You should now be able to cross-compile to every desktop OS using e.g.:

zig build -Dtarget=x86_64-windows
zig build -Dtarget=x86_64-linux-gnu
zig build -Dtarget=x86_64-macos
zig build -Dtarget=aarch64-macos

Questions? Ran into an issue?

Make sure you’re using a supported Zig version

There are two ways to get help: