This repository gathers Zig code examples coming from various websites and books. It also includes several build scripts (batch files, Make scripts) for experimenting with Zig on a Windows machine. |
Ada, Akka, C++, COBOL, Dafny, Dart, Deno, Docker, Flix, Go, GraalVM, Haskell, Kafka, Kotlin, LLVM, Modula-2, Node.js, Rust, Scala 3, Spark, Spring, TruffleSqueak and WiX Toolset are other topics we are continuously monitoring.
This project depends on two external software for the Microsoft Windows platform:
Optionally one may also install the following software:
- ConEmu 2023 (release notes)
- SDL 2 (release notes)
- SDL 3 (release notes)
- Visual Studio Code 1.95 (release notes)
- Zig 0.14 DEV
🔎 Git for Windows provides a BASH emulation used to run
git
from the command line (as well as over 250 Unix commands likeawk
,diff
,file
,grep
,more
,mv
,rmdir
,sed
andwc
).
For instance our development environment looks as follows (December 2024) 1:
C:\opt\ConEmu\ ( 26 MB) C:\opt\Git\ (393 MB) C:\opt\SDL2\ ( 21 MB) C:\opt\SDL3\ ( 49 MB) C:\opt\zig-0.13.0\ (293 MB) C:\opt\zig-0.14.0-dev\ (269 MB) C:\opt\VSCode\ (371 MB)
☛ Installation policy
When possible we install software from a Zip archive rather than via a Windows installer. In our case we definedC:\opt\
as the installation directory for optional software tools (similar to the/opt/
directory on Unix).
Directory structure ▴
This project is organized as follows:
bin\*.bat docs\ examples\{README.md, hello} sdl-examples\{README.md, hello-gamedev, hello-gamedev-sdl3} README.md RESOURCES.md setenv.bat
where
- directory
bin\
provides several utility batch files. - directory
docs\
contains Zig related papers/articles. - directory
examples\
contains Zig code examples (seeREADME.md
). - file
README.md
is the Markdown document for this page. - file
RESOURCES.md
is the Markdown document presenting external resources. - file
setenv.bat
is the batch script for setting up our environment.
We also define a virtual drive – e.g. drive H:
– in our working environment in order to reduce/hide the real path of our project directory (see article "Windows command prompt limitation" from Microsoft Support).
🔎 We use the Windows external command
subst
to create virtual drives; for instance:> subst H: %USERPROFILE%\workspace\zig-examples
In the next section we give a brief description of the batch files present in this project.
Batch commands ▴
We execute command setenv.bat
once to setup our development environment:
> setenv Tool versions: zig 0.13.0, make 4.4.1, SDL2 2.30.10.0, SDL3 3.1.6.0, git 2.47.1, diff 3.10, bash 5.2.37(1)
Usage examples ▴
Command setenv.bat
with option -verbose
displays additional information:
- the tool paths (which may not contain the version suffix, i.e.
C:\opt\Git\bin\git.exe
in some installations), - the environment variables defined locally within this session,
- and the path associations (i.e.
H:\
in this case, but other drive names may be displayed as path associations are globally defined).
> setenv -verbose Tool versions: zig 0.13.0, make 4.4.1, SDL2 2.30.10.0, SDL3 3.1.6.0, git 2.47.1, diff 3.10, bash 5.2.37(1) Tool paths: C:\opt\zig-0.13.0\zig.exe C:\opt\msys64\usr\bin\make.exe C:\opt\Git\bin\git.exe C:\opt\Git\usr\bin\diff.exe C:\opt\Git\bin\bash.exe Environment variables: "GIT_HOME=C:\opt\Git" "MSYS_HOME=C:\opt\msys64" "SDL2_HOME=C:\opt\sdl2" "SDL3_HOME=C:\opt\sdl3" "ZIG_HOME=C:\opt\zig-0.13.0" Path associations: H:\: => %USERPROFILE%\workspace-perso\zig-examples
Footnotes ▴
[1] Downloads ↩
- In our case we downloaded the following installation files (see section 1):
-
ConEmuPack.230724.7z ( 5 MB) PortableGit-2.47.1-64-bit.7z.exe ( 41 MB) SDL2-devel-2.30.10-VC.zip ( 6 MB) SDL3-devel-3.1.6-VC.zip ( 13 MB) VSCode-win32-x64-1.95.3.zip (131 MB) zig-windows-x86_64-0.13.0.zip ( 75 MB) zig-windows-x86_64-0.14.0-dev.2051+b1361f237.zip ( 80 MB)