Error linking Raylib via raylib-zig

The addRaylib function is part of raylib/src/build.zig at master · raysan5/raylib · GitHub the function is part of raylib and is used by some people to add raylib to their projects. (It seems Not-Nik/raylib-zig doesn’t use that function and instead writes its own function however it seems that code gets loaded and run together with the main build.zig causing the error message)

The problem is that Not-Nik/raylib-zig uses https://github.com/raysan5/raylib/archive/5.0.tar.gz if you download that and look into it, you can see that that uses std.Build.CompileStep in src/build.zig however you are trying to compile it with a version of zig that is too new where it needs to be updated to std.Build.Step.Compile.

You have 3 options:

  1. you downgrade to an older version of zig somewhere between your current version and the one specified in Not-Nik/raylib-zig’s readme:

    Bindings tested on raylib version 5.0 and Zig 0.11.0/0.12.0-dev.1849+bb0f7d55e

    (I don’t know the exact versions that work besides what the readme states, there could be other incompatibilities.)

  2. you update Not-Nik/raylib-zig build.zig.zon’s url+hash to point to a newer raylib commit and update Not-Nik/raylib-zig’s build.zig if necessary.

  3. Alternatively you could try using raylib directly without the bindings (that is what I am doing, one indirection less to worry about), here is an example project: Raylib example using the package manager

Either way let us know what you have tried and if it worked, or presented you with any other errors.

Personally I think 2. is probably your best choice if you are used to using the bindings and should be doable, the difficult thing is just getting used to the whole picking commits and what to do to update stuff.

1 Like