Welcome to Zag! This guide will walk you through setting up the Zag compiler and building your very first program.
Before we begin, ensure you have the following installed on your system:
gcc, clang, or cc available in your $PATH.First, download the Zag source code from GitHub:
git clone https://github.com/dtasada/zag.git
cd zag
Zag uses the standard Zig build system. You can build the compiler executable with a single command:
zig build install --prefix ~/.local
This will copy the zag compiler into ~/.local/bin/zag. If ~/.local/bin/ is in your $PATH, running zag will work. If not, add ~/.local/bin to your $PATH.
You could also choose any other install prefix.
Create a new file at src/main.zag in the root directory:
// hello.zag
bind fn printf(fmt: &c_char, args...) c_int;
fn main() i32 {
printf("Hello, Zag world!\n");
return 0;
}
# Run the build command
zag build
.zag-out/bin/main.Try running it:
./.zag-out/bin/main
xcode-select --install. On Ubuntu, run sudo apt install build-essential.zig version reports 0.15.0 or higher.