-
Notifications
You must be signed in to change notification settings - Fork 132
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Linker error for raygui functions when building shared on Windows #147
Comments
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? |
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.
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 |
I found some time again to tackle this project again and I experimented a bit further. The build works fine on linux and ld can link the raygui items with 0 issues meanwhile on windows the issue still persists even with the latest library version. I got some time to spend on this if you could hint me towards what should be done to test for the windows case. |
Unfortunately, I really have no idea what could be causing this, but chances are that it's a Zig bug that is fixed in the upcoming 0.14 release (look out for #185). In the meantime, if you need to be developing on Windows, you could trying using WSL2 which does support X11. |
Sadly it is something I need to send out to a windows user. I'll see if I can get imGui working or well might as well make the UI myself. Thanks! Should we close this? |
Alternatively, just link statically (no need for hot-reloading when shipping, right?), or try including Let's leave this open for reference until it is actually fixed :) |
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
The text was updated successfully, but these errors were encountered: