raylib.zig icon indicating copy to clipboard operation
raylib.zig copied to clipboard

Error building raylib

Open gustavojoaquin opened this issue 1 year ago • 10 comments

Hi, i followed the instruction in the documentation, but i have this error:

error: struct 'target.Target' has no member named 'Query'
pub fn addTo(b: *std.Build, exe: *std.Build.Step.Compile, target: std.Target.Query, optimize: std.builtin.Mode, raylibOptions: raylib_build.Options) void {
                                                                  ~~~~~~~~~~^~~~~~
/usr/lib/zig/std/target.zig:6:20: note: struct declared here
pub const Target = struct {
                   ^~~~~~
referenced by:
    build: /media/gus/proyectos/wolfenstein_3d_zig/build.zig:28:11
    runBuild__anon_7136: /usr/lib/zig/std/Build.zig:1638:27
    remaining reference traces hidden; use '-freference-trace' to see all reference traces

my zig version is: 0.11.0

gustavojoaquin avatar Mar 24 '24 20:03 gustavojoaquin

I'm having a similar issue. When looking at the Zig standard library documentation, Query certainly exists as a type inside of Target, but when I checked my local files, I found no definition or even reference to Query. When I ran zig version, I also received 0.11.0.

Axiomatic-Mind avatar Mar 25 '24 17:03 Axiomatic-Mind

Same problem but with master version: 0.13.0-dev.245+5fe9f88b1:

const std = @import("std");
const rl = @import("raylib/build.zig");

pub fn build(b: *std.Build) void {
    const target = b.standardTargetOptions(.{});
    const optimize = b.standardOptimizeOption(.{});

    const exe = b.addExecutable(.{
        .name = "zigaroids",
        .root_source_file = b.path("src/main.zig"),
        .target = target,
        .optimize = optimize,
    });

    rl.addTo(b, exe, target, optimize, .{});

    b.installArtifact(exe);

    const run_exe = b.addRunArtifact(exe);
    b.step("run", "Run Zigaroids!").dependOn(&run_exe.step);
}

With error:

expected type 'Target.Query', found 'Build.ResolvedTarget'
    rl.addTo(b, exe, target, optimize, .{});
                     ^~~~~~
/home/fenilli/.zig/zig-0.13.0-dev/lib/std/Build.zig:2485:28: note: struct declared here
pub const ResolvedTarget = struct {
                           ^~~~~~
/home/fenilli/.zig/zig-0.13.0-dev/lib/std/Target/Query.zig:1:1: note: struct declared here
//! Contains all the same data as `Target`, additionally introducing the

Edit:

Changing the target rl.addTo(b, exe, target, optimize, .{}); to query rl.addTo(b, exe, target.query, optimize, .{}); gives this error:

 error: no field named 'path' in union 'Build.LazyPath'
    exe.root_module.addAnonymousImport("raylib", .{ .root_source_file = .{ .path = cwd ++ sep ++ "raylib.zig" } });
                                                                            ^~~~
/home/fenilli/.zig/zig-0.13.0-dev/lib/std/Build.zig:2133:22: note: union declared here
pub const LazyPath = union(enum) {

fenilli avatar May 23 '24 22:05 fenilli

same problem on 0.12.0

leg7 avatar May 24 '24 20:05 leg7

path field in LazyPath is deprecated as of 0.12.0. We can probably fix this by using std.Build.path instead.

0komo avatar Jun 04 '24 05:06 0komo

Maybe try https://github.com/ryupold/raylib.zig/pull/41#issuecomment-2156182817 like I did? Worked for me at Zig 0.12

ziontee113 avatar Jun 08 '24 21:06 ziontee113

FYI this is all builtin to raylib:

  • https://github.com/raysan5/raylib/blob/master/build.zig
  • https://github.com/raysan5/raylib/blob/master/src/build.zig

Instructions here worked for me: https://www.reddit.com/r/Zig/comments/16r0fj6/ysk_you_can_use_native_raylib_directly_in_zig_for/

melMass avatar Jun 12 '24 10:06 melMass

FYI this is all builtin to raylib:

  • https://github.com/raysan5/raylib/blob/master/build.zig
  • https://github.com/raysan5/raylib/blob/master/src/build.zig

Instructions here worked for me: https://www.reddit.com/r/Zig/comments/16r0fj6/ysk_you_can_use_native_raylib_directly_in_zig_for/

You can, that is what I'm using, but those are not crafted with zig in mind, they are just direct translations so you have to do bit casting and all by hand, just a bit more work over a working binding.

fenilli avatar Jun 12 '24 15:06 fenilli

Same problem with zig 0.14.0

 error: no field named 'path' in union 'Build.LazyPath'
    exe.root_module.addAnonymousImport("raylib", .{ .root_source_file = .{ .path = cwd ++ sep ++ "raylib.zig" } });
                                                                            ^~~~
/home/fenilli/.zig/zig-0.13.0-dev/lib/std/Build.zig:2133:22: note: union declared here
pub const LazyPath = union(enum) {

RokibulUddin avatar Jul 29 '24 12:07 RokibulUddin

Anybody got a solution for this? I too experience this on zig 0.13 SNAP package on Ubuntu. It's driving me crazy, I have no idea how to solve this.

/devel/zig-game/raylib/build.zig:102:77: error: no field named 'path' in union 'Build.LazyPath' exe.root_module.addAnonymousImport("raylib", .{ .root_source_file = .{ .path = cwd ++ sep ++ "raylib.zig" } }); ^~~~ /snap/zig/11625/lib/std/Build.zig:2171:22: note: union declared here pub const LazyPath = union(enum) { ^~~~~

rdoetjes avatar Aug 23 '24 14:08 rdoetjes

Check PR #46

0komo avatar Aug 24 '24 13:08 0komo