Closed MassKlaus closed 1 month ago
Hey @MassKlaus, have you made sure to add the raygui import in the build.zig? I copied your main file 1:1, but here is my build file (minus the web export code).
const std = @import("std");
const rlz = @import("raylib-zig");
pub fn build(b: *std.Build) !void {
const target = b.standardTargetOptions(.{});
const optimize = b.standardOptimizeOption(.{});
const raylib_dep = b.dependency("raylib-zig", .{
.target = target,
.optimize = optimize,
.shared = true,
});
const raylib = raylib_dep.module("raylib");
const raygui = raylib_dep.module("raygui"); // note this line
const raylib_artifact = raylib_dep.artifact("raylib");
const exe = b.addExecutable(.{ .name = "shared_gui", .root_source_file = b.path("src/main.zig"), .optimize = optimize, .target = target });
exe.linkLibrary(raylib_artifact);
exe.root_module.addImport("raylib", raylib);
exe.root_module.addImport("raygui", raygui); // note this line
const run_cmd = b.addRunArtifact(exe);
const run_step = b.step("run", "Run shared_gui");
run_step.dependOn(&run_cmd.step);
b.installArtifact(exe);
}
Using Zig 0.13 and the latest version of these bindings, everything builds fine. Here is the result:
raygui is added to the build regardless of configuration, just like any other raylib source file. As @ZackeryRSmith said, this is probably a build misconfig on your end.
Sorry for the late reply but yeah, I forgot to include my full build script but it was the default zig-init build script with the raylib-zig bindings imports for both raylib and raygui. I copied your build script and still ran into the same issue. I am on windows, so maybe a compiler thing?
I am on windows, so maybe a compiler thing?
It is strange that this only occurs when building as a shared library. I don't think it's an issue with building on Windows. However if that is the case: the issue is likely with Raylib's build.zig and is a separate issue unrelated to this project.
I cannot reproduce this error on my machine sadly, so it's hard for me to debug. Although I'm a bit lost here... To be clear though: What version of Zig are you using and how are you installing the bindings.
Main reason for trying to build raylib and raygui as a shared library is implementing hot reloading eventually
I guess for the moment just ignore building as a shared library. Once I have the chance I will try debugging this on my Windows VM.
I am using Zig 0.13.0 and the bindings are fetched as indicated in the ReadMe of the project. I've just reinstalled my system so I'll a chance later and test in wsl 2 when I can.
A lot of thanks!
Any updates? Otherwise I'll close this, since it seems resolved and I can't repro it on my machine.
I wasn't really able to figure out what was happening sadly, wsl doesn't have x11 and couldn't push for more so for now it's best to close till someone else has some similar issue
Error:
Adding the .shared = true when using raygui breaks things
buid.zig:
main.zig
Main reason for trying to build raylib and raygui as a shared library is implementing hot reloading eventually