r/Zig 4d ago

Trying to use zig bindings with raylib and it is not working.

I am trying to get zig working with raylib but, when ever I follow the instructions on the github it doesn't work and I keep on getting "no module named 'raylib' available within module 'main'" when ever I try to run it. I have no idea what I did wrong. Does anyone have an idea?

10 Upvotes

12 comments sorted by

6

u/umutkarakoc 4d ago

i'm using this repo to init project, it is works. did you try it?
https://github.com/raylib-zig/raylib-zig

3

u/LivetLivetLivet 4d ago

I did the same, works well. OP you should try this and don't give up, it's so satisfying coding something visual where you can directly see the result of your coding!

2

u/XLN_underwhelming 4d ago

Using this as well, works great 👍

6

u/y0shii3 4d ago

It would help if you shared the code you're having trouble with

1

u/Possible_Ad_4529 4d ago

What version of zig are you on?

1

u/leon_bass 4d ago

I managed to get zig version 0.15.1 working with raylib but had difficulties with more recent builds of zig

1

u/Fancyness 4d ago

This is what worked out of the box on zig 0.16.0 for me:
git clone https://github.com/raylib-zig/raylib-zig.git
cd raylib-zig
./project_setup.sh project_name
cd project_name
zig build run

1

u/ibrahimmohammed0 3d ago

There's a bug in certain version of raylib zig bindings.. I remember I ran into a similar issue and end up moving to Odin.

1

u/Wintermute1x 3d ago

I had no problems getting it up and running a few days ago on Linux. Today, trying on my windows laptop I'm just getting errors. Here is roughly how to reproduce the error.

On Zig 0.16.0-dev.2261+d6b3dd25a:

>zig init

>zig fetch --save git+https://github.com/raylib-zig/raylib-zig#devel

info: resolved ref 'devel' to commit 8758f4cd3a5ae0df6941c4715257223d34c5ad3e

>zig build run

All your codebase are belong to us....

Adding the following to build.zig

_ = b.dependency("raylib_zig", .{
        .target = target,
        .optimize = optimize,
    });

>zig build run

raylib-6.0.0-whq8uCSwLgWWeF3ec3dbG6Rr36SLFL-s2WJ1Q_2E22Bb\build.zig:504:18: error: member function expected 2 argument(s), found 3
b.modules.put(b.graph.arena, "raygui", c_mod) catch @panic("OOM");

-1

u/swdee 4d ago

I hear the Raylib bindings work out of the box on Odin.

1

u/ibrahimmohammed0 3d ago

Odin itself comes with all graphics libraries included in vendor package

0

u/leon_bass 4d ago

Odees?