Installation
This guide covers installing the gab language. This includes development files, as well as the binaries and builtin package.
Choose your release
Pre-built binaries are available for every release on the GitHub releases page. Links are provided below for your convenience. Download the archive that matches your platform:
| Platform | Architecture | File |
|---|---|---|
| macOS | x86-64 | gab-x86-64-macos |
| macOS | arm 64 | gab-aarch64-macos |
| Windows | x86-64 | gab-x86-64-windows |
| Windows | arm 64 | gab-aarch64-windows |
| Linux | x86-64 | gab-x86-64-linux |
| Linux | arm 64 | gab-aarch64-linux |
Warning
On certain platforms, the executable you just downloaded (gab-<your_target>) will need to be marked as executable in order to run it.
Install
Info
The executable you just downloaded (gab-<your_target>) won’t be in your path, so you’ll need to invoke it directly.
Gab installs binaries into a platform-specific location. It is recommended to add this directory to your $PATH.
To see where gab installs binaries, use the -n flag to explain download/installation steps.
Test the downloaded binary
From this point forward lets refer to your downloaded binary as simply gab, just to make things easier.
Now, you should be able to run Gab.
# Try this:
gab
# Or this:
gab helpYou should see a generic help message, summarazing the commands available to you.
However, at this point trying to run any real code will fail - Gab’s core modules still need to be installed. Lets verify this with gab info.
Check your Gab installations
gab info
# At the end of the output, you should see something like:
<version> TARGETS
x64 linux | not installed
x64 macos | not installed
x64 windows | not installed
arm linux | not installed
arm macos | not installed
arm windows | not installedAha! No installations were found. Lets go ahead and complete your installation.
Download and install Gab locally
# Gab makes this easy:
gab getThis command downloads packages. When no package is specified (as above), it downloads the builtin gab-language/cgab package, and the gab binary itself.
A ‘package’ is a resource attached to a tag on a git remote. The only supported host thus far is github.
To manually download the builtin gab package, the command would look something like:
gab get github.com/gab-language/cgab@0.1.3From this example, gab constructs the url:
https://github.com/gab-language/cgab/releases/downloads/0.1.3/cgab-0.1.3-x86_64-linux-gnuWhen other hosts become officially supported, gab will construct URLs to match their needs.
If this resources exists, gab downloads it expecting a gab bundle, which it then installs as a package.
Note
gab calls out to the operating system for curl in order to perform this installation. They should be widely available by default on most machines,
including any Windows machine with Windows 10 or later. However, you may see an error message indicating that it is unavailable - in this case, installation will fail.
The resource name cgab-0.1.1-x86_64-linux-gnu is a canonical gab bundlename. It is composed of 5 parts, separated with -.
- The gab implementation
- The version of said gab implementation
- The machine architecture
- The operating system
- The libc implementation
These components ensure that gab searches for and downloads code matching the desired target exactly.
Complete the installation
At this point, you have a gab version installed correctly on your machine. In order to use it however, you’ll need to add it to your PATH.
Running gab info again should show that you’ve installed the appropriate target. You can install the same binary and builtin package for any platform that you like - this is actually how Gab supports cross compilation!
If your system supports symbolic links, it is recommended to link the gab binary found in the local installation to some folder already in your PATH, like /usr/local/bin on Linux.
And thats it - Gab is now installed and ready to go on your system. If you’re new to Gab, start with the gabonomicon. Get hacking!
Compiling From Source
cgab is a C project built with Zig’s c-compiler toolchain. zig cc is chosen specifically for its cross-compiling superpowers. This enables
linux developers to cross-compile for Windows and run via wine, among other amazing things. As a result, a limitation placed on cgab is that there
shall be no runtime dependencies other than libc. This constraint is what makes the cross compilation possible. This goes for any c modules as well - there
may be NO runtime dependencies. Any 3rd party code necessary for c modules shall be kept in git-submodules, and if it must be linked, then linked statically.
Unix Systems
To manage the various useful scripts in the repo, cgab takes advantage of clide.
After installing clide, building cgab from source is as simple as running:
clide buildClide will prompt you to select a build type and installation target. For details on how to use clide, check its readme.
Manual Build
Alternatively, zig cc can be invoked manually. Check .clide/../build.sh for an example of how to invoke zig cc, and build the appropriate artifacts.
Note
The additional flags -DGAB_PLATFORM_UNIX and -D_POSIX_C_SOURCE=200809L are required for unix builds.
Clide relies on bash scripts written in the .clide/ directory, and therefore will not work on windows.
On Windows, zig cc should be invoked manually. The following is an example, but will not fully build cgab.
zig cc -Os -std=c23 -fPIC -Wall --target=native -o gab -Iinclude -Ivendor -DNDEBUG -DGAB_PLATFORM_WIN src/**/*.c