Skip to content
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

Does this work with the master branch of raylib? - Zig Compilation Error #417

Closed
nat3Github opened this issue Jul 23, 2024 · 2 comments
Closed

Comments

@nat3Github
Copy link

Does this work with the master branches of raylib?
in zig I'm pulling from raylib and raygui master and get compile Errors inside an cImport.

@raysan5
Copy link
Owner

raysan5 commented Jul 23, 2024

@nat3Github yes, it should, I always work with raylib and raygui master branches

@nat3Github nat3Github changed the title Does this work with the master branch of raylib? Does this work with the master branch of raylib? - Zig Compilation Error Jul 23, 2024
@VisenDev
Copy link

VisenDev commented Jul 24, 2024

Zig compiles raygui.h using clang. Clang compiles c header files differently than it does normal c files. So you will get a compile error compiling raygui.h with zig in the normal way. See ziglang/zig#19423

You need to do something like this

build.zig

    const raylib_dep = @import("raylib");

    const ray = try raylib_dep.addRaylib(b, target, optimize, .{ .raygui = true });
    exe.linkLibrary(ray);

build.zig.zon

     .raylib = .{
         .url = "https://github.com/raysan5/raylib/archive/f5d2f8d.tar.gz",
         .hash = "12201c7e120800ecf29429560eefb2f2df58a176ee1f949e9e275944df048e0c22b2",
     },
     .raygui = .{
         .url = "https://github.com/raysan5/raygui/archive/refs/heads/master.tar.gz",
         .hash = "1220c62ef63613b8cb2893748d6baa344cd2d994328fbf3fe7559bec00a144c991e5",
     },

import raygui like this

main.zig

const ray = @cImport({
    @cInclude("raylib.h");
});

const raygui = @cImport({
    @cInclude("raygui.h");
});

@raysan5 raysan5 closed this as completed Aug 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants