Skip to content

Instantly share code, notes, and snippets.

@GeroZayas
Created January 2, 2026 09:00
Show Gist options
  • Select an option

  • Save GeroZayas/42b7e0057a5f3adf70c523a4d954d0ec to your computer and use it in GitHub Desktop.

Select an option

Save GeroZayas/42b7e0057a5f3adf70c523a4d954d0ec to your computer and use it in GitHub Desktop.
Compile RAYLIB App with Zig (C99)
zig cc -std=c99 main.c \
-lraylib -lGL -lm -lpthread -ldl -lrt -lX11 \
-o app
@GeroZayas

Copy link
Copy Markdown
Author

Linker flags (-l...)

These tell the linker what libraries to include when producing the final executable.

-lraylib
Link Raylib library itself (the implementation for all those functions like InitWindow).
You installed Raylib earlier via make && sudo make install.
GitHub

-lGL
Link OpenGL (graphics). Raylib uses OpenGL for rendering.
On Ubuntu this comes from packages like libgl1-mesa-dev.
GitHub

-lm
Link math library (libm). Functions like sin/cos come from here.

-lpthread
Link POSIX threads (multithreading). C runtime needs this for some systems.

-ldl
Link dynamic loader helper. Required for loading shared modules at runtime.

-lrt
Link real-time extensions, e.g., high-precision timers.

-lX11
Link X11 window system.
Raylib opens a window using X11 on Linux, so you need the X11 libs (libx11-dev).

@GeroZayas

Copy link
Copy Markdown
Author

-o app

Name the output executable app.

Without -o, Zig would pick a default name.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment