This document provides a basic setup for a C project utilizing the Zig build system. It should simplify the process of setting up a new project especially for beginners (like me).
- Install Zig
Run the following command to build and run the project:
zig build run
.
├── build.zig # build script
└── src # source files
├── main.c
├── lib.h
└── lib.c
!!! note
If you have added or removed files, you need to update the list of files in the build.zig
file, in the exe.addCSourceFiles
section:
exe.addCSourceFiles(.{
.files = &.{
"src/main.c",
"src/lib.c",
+ "src/another_file.c",
},
});