Hello, World!
To compile and build a Zig program, follow these steps:
Install Zig: Download and install Zig from the official website.
Write Your Zig Code: Create a file named
main.zigwith your Zig code. For example:const std = @import("std"); pub fn main() void { std.debug.print("Hello, World!\n", .{}); }Open Terminal: Navigate to the directory containing your
main.zigfile.Compile the Zig Code: Use the
zig build-execommand to compile your Zig code into an executable.zig build-exe main.zigRun the Executable: After compilation, run the generated executable.
./main
These steps will compile and build your Zig program, allowing you to run the resulting executable.
Last modified: 20 November 2024