To use a specific version of raylib-zig instead of the one bundled with DVUI, you must configure the dvui dependency in your build.zig and manually inject your raylib and raygui modules into the DVUI backend module. This prevents dependency conflicts between your project and the library.
Follow these steps in your build.zig:
- Load the
dvui dependency with the .raylib_zig backend. - Access the
raylib_zig module from the dependency. - Use
addImport to map your project's raylib and raygui dependencies to the backend module. - Import the
dvui_raylib module and the modified backend module into your executable.
// In build.zig while loading the dvui dependency
const dvui_dep = b.dependency("dvui", .{
.target = target,
.optimize = optimize,
.backend = .raylib_zig,
});
// Inject your own raylib dependencies to prevent conflicts
const backend_mod = dvui_dep.module("raylib_zig");
backend_mod.addImport("raylib", raylib); // from your raylib dependency
backend_mod.addImport("raygui", raygui);
exe.root_module.addImport("dvui", dvui_dep.module("dvui_raylib"));
exe.root_module.addImport("backend", backend_mod);