Knowing that we would remove @cImport at some point, I had a little trouble trying to import Raylib using std.Build.addTranslateC. It turns out it wasn’t as simple as I thought.
Anyway, here’s the resulting code snippet:
pub fn build(b: *std.Build) void {
...
//get the raylib artifact from dependencies
const raylib = b.dependency(
"raylib",
.{ .target = target, .optimize = optimize },
).artifact("raylib");
//raylib bindings
const translate_raylib = b.addTranslateC(.{
.target = target,
.optimize = optimize,
.root_source_file = b.addWriteFiles().add("all.h",
\\#include <raylib.h>
\\#include <rcamera.h>
\\#include <raymath.h>
\\#include <rlgl.h>
),
});
//Little hack to include the raylib headers
// another way to do this is just:
// translate_raylib.addIncludePath(raylib_dep.path("src"));
//I do think this is more correct through, as it doesn't
// depends on the internal folder structure of raylib
translate_raylib.include_dirs.append(.{ .other_step = raylib })
catch @panic("OOM");
translate_raylib.step.dependOn(&raylib.step);
//Finish by linking to the raylib
const raylib_mod = translate_raylib.createModule();
raylib_mod.linkLibrary(raylib);
main_exe.root_module.addImport("raylib", raylib_mod);
...
}
I tried installing wayland-scanner with pacman and yay, but the package doesn’t exist. Do I need to install something else or is there something wrong with build.zig ?
Edit:
Additional info:
KDE Plasma Version: 6.6.5
KDE Frameworks Version: 6.26.0
Qt Version: 6.11.1
Kernel Version: 7.0.10-artix1-1 (64-bit)
Graphics Platform: Wayland
It seems the signature of findProgram changed to accept a FindProgramOptions struct. This error comes from raylib, so you’ll have to wait until raylib updates, which will probably only happen when 0.17 is released. In the meantime, you can use zig 0.16, which should work.
Here’s my version of it.
I misread this thread thinking that you didn’t have it working, turns out what I’ve impl is pretty much the same as yours. I love myself.