mirror of
https://github.com/raysan5/raylib.git
synced 2026-04-20 14:03:40 -04:00
* Add better structure for build.zig Temporarily disabled the tests * Cleanup build.zig a bit * Fixed zemscripten and cleanup other platforms * Make opengl_version selection more restritive * Add traslateC to build; Renable examples * Add raygui build to build.zig * Deny glfw from android target * Fix android platform includes * Add Zig project example * Add Zig project mention to README * Set right name for web build in zig example * Cleanup last parts of build.zig * Add linking method for build.zig * Fix lshcore link for glfw and rgfw build.zig * Fix weird sdl linkage build.zig * Add zig example to zig project * Fix win32, mac build bugs in build.zig * Rename argument lshcore to shcore build.zig
Starting your raylib project with Zig (0.16.0)
How to compile and run it
To compile the project:
zig build
To run the project:
zig build run
Compile with different optimization
To change from debug to release build you can do it with the -Doptimze= flag.
Debug
ReleaseSafe
ReleaseFast
ReleaseSmall
Choose a different platform
To compile with a different platform you can use the -Dplatform= flag.
Here all the options:
glfw
rgfw
sdl
sdl2
sdl3
memory
win32
drm
android
In this example the platform sdl and sdl2 are not supported
Important for the android platform you also have to compile for the right target
Compile for a different target
To compile for a different target you can use the -Dtarget= flag.
Not all targets are supported
Example: Compile for web and run it
To compile for the web we use emscripten and you run it like that:
zig build -Dtarget=wasm32-emscripten
To run it we do:
zig build run -Dtarget=wasm32-emscripten
And to make a relase build we do:
zig build -Dtarget=wasm32-emscripten -Doptimize=ReleaseFast
If we want to use rgfw for the web build we could do:
zig build -Dplatform=rgfw -Dtarget=wasm32-emscripten -Doptimize=ReleaseFast
Compiling the Zig code? Just add -Dzig and try out zig ;)
More Resources
See Zig Build System