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

Zig doesn't find X11 headers #17

Open
dimchee opened this issue Sep 25, 2024 · 1 comment
Open

Zig doesn't find X11 headers #17

dimchee opened this issue Sep 25, 2024 · 1 comment

Comments

@dimchee
Copy link

dimchee commented Sep 25, 2024

Hello,

I was trying to use raylib in my zig project. However, it is not compiling. I tried to find the issue, so I tried to locate which packages are missing, as I have a simple setup with pkgs.mkShell which works. I concluded that the problem is
pkgs.mkShellNoCC, I can replicate it on my simple setup too, but i can't locate which dependency from stdenv I am missing. Output of zig compiler:

install
└─ install <name>
   └─ zig build-exe <name> Debug native
      └─ zig build-lib raylib Debug native 1 errors
/home/dimchee/.cache/zig/p/1220aa75240ee6459499456ef520ab7e8bddffaed8a5055441da457b198fc4e92b26/src/external/glfw/src/x11_platform.h:36:10: error: 'X11/Xcursor/Xcursor.h' file not found
#include <X11/Xcursor/Xcursor.h>
         ^~~~~~~~~~~~~~~~~~~~~~~~
/home/dimchee/.cache/zig/p/1220aa75240ee6459499456ef520ab7e8bddffaed8a5055441da457b198fc4e92b26/src/rglfw.c:73:10: note: in file included from /home/dimchee/.cache/zig/p/1220aa75240ee6459499456ef520ab7e8bddffaed8a5055441da457b198fc4e92b26/src/rglfw.c:73:
#include "external/glfw/src/init.c"
         ^
/home/dimchee/.cache/zig/p/1220aa75240ee6459499456ef520ab7e8bddffaed8a5055441da457b198fc4e92b26/src/external/glfw/src/init.c:28:10: note: in file included from /home/dimchee/.cache/zig/p/1220aa75240ee6459499456ef520ab7e8bddffaed8a5055441da457b198fc4e92b26/src/external/glfw/src/init.c:28:
#include "internal.h"
         ^
/home/dimchee/.cache/zig/p/1220aa75240ee6459499456ef520ab7e8bddffaed8a5055441da457b198fc4e92b26/src/external/glfw/src/internal.h:325:10: note: in file included from /home/dimchee/.cache/zig/p/1220aa75240ee6459499456ef520ab7e8bddffaed8a5055441da457b198fc4e92b26/src/external/glfw/src/internal.h:325:
#include "platform.h"
         ^
/home/dimchee/.cache/zig/p/1220aa75240ee6459499456ef520ab7e8bddffaed8a5055441da457b198fc4e92b26/src/external/glfw/src/platform.h:81:11: note: in file included from /home/dimchee/.cache/zig/p/1220aa75240ee6459499456ef520ab7e8bddffaed8a5055441da457b198fc4e92b26/src/external/glfw/src/platform.h:81:
 #include "x11_platform.h"
          ^
error: warning(compilation): failed to delete '/home/dimchee/Desktop/raylib/testRl/.zig-cache/tmp/c94073d7ddf2101c-rglfw.o.d': FileNotFound

error: the following command failed with 1 compilation errors:
/nix/store/x4i1lfr4xw58w3rrnyxcmbpp19i6a3gw-zig-0.13.0/bin/zig build-lib -I/nix/store/0nifpiwvav0p4nh67w5vzy3xfdy2m50g-libglvnd-1.7.0-dev/include -L/nix/store/shvpkfqpaas60fakhw62hp3xgpfh4kdm-libglvnd-1.7.0/lib -lGL -I/nix/store/9rcc4vw6140z5s306jmppnfcys5782mk-libX11-1.8.10-dev/include -I/nix/store/8vqwsvmx9idbiypfddgf1r94ns3yc7i7-xorgproto-2024.1/include -L/nix/store/llfrkl8va8kv49q0ymqwx04apa52mck3-libX11-1.8.10/lib -lX11 -cflags -std=gnu99 -D_GNU_SOURCE -DGL_SILENCE_DEPRECATION=199309L -fno-sanitize=undefined -- /home/dimchee/.cache/zig/p/1220aa75240ee6459499456ef520ab7e8bddffaed8a5055441da457b198fc4e92b26/src/rcore.c /home/dimchee/.cache/zig/p/1220aa75240ee6459499456ef520ab7e8bddffaed8a5055441da457b198fc4e92b26/src/utils.c /home/dimchee/.cache/zig/p/1220aa75240ee6459499456ef520ab7e8bddffaed8a5055441da457b198fc4e92b26/src/raudio.c /home/dimchee/.cache/zig/p/1220aa75240ee6459499456ef520ab7e8bddffaed8a5055441da457b198fc4e92b26/src/rmodels.c /home/dimchee/.cache/zig/p/1220aa75240ee6459499456ef520ab7e8bddffaed8a5055441da457b198fc4e92b26/src/rshapes.c /home/dimchee/.cache/zig/p/1220aa75240ee6459499456ef520ab7e8bddffaed8a5055441da457b198fc4e92b26/src/rtext.c /home/dimchee/.cache/zig/p/1220aa75240ee6459499456ef520ab7e8bddffaed8a5055441da457b198fc4e92b26/src/rtextures.c /home/dimchee/.cache/zig/p/1220aa75240ee6459499456ef520ab7e8bddffaed8a5055441da457b198fc4e92b26/src/rglfw.c -cflags -std=gnu99 -D_GNU_SOURCE -DGL_SILENCE_DEPRECATION=199309L -fno-sanitize=undefined -- /home/dimchee/Desktop/raylib/testRl/.zig-cache/o/ec6be00b9a4f00e4bc20631af1f78af7/raygui.c -ODebug -I /home/dimchee/.cache/zig/p/1220aa75240ee6459499456ef520ab7e8bddffaed8a5055441da457b198fc4e92b26/src/external/glfw/include -I /usr/include -I /home/dimchee/.cache/zig/p/1220aa75240ee6459499456ef520ab7e8bddffaed8a5055441da457b198fc4e92b26/src -I /home/dimchee/.cache/zig/p/122002d98ca255ec706ef8e5497b3723d6c6e163511761d116dac3aee87747d46cf1/src -D_GLFW_X11=1 -DPLATFORM_DESKTOP=1 -L /usr/lib -Mroot -lc --cache-dir /home/dimchee/Desktop/raylib/testRl/.zig-cache --global-cache-dir/home/dimchee/.cache/zig --name raylib -static --listen=-
Build Summary: 2/6 steps succeeded; 1 failed (disable with --summary none)
install transitive failure
└─ install <name> transitive failure
   └─ zig build-exe <name> Debug native transitive failure
      └─ zig build-lib raylib Debug native 1 errors
error: the following build command failed with exit code 1:
/home/dimchee/Desktop/raylib/testRl/.zig-cache/o/60dc6d61ff71892df29ecc7ed456da5a/build /nix/store/x4i1lfr4xw58w3rrnyxcmbpp19i6a3gw-zig-0.13.0/bin/zig /home/dimchee/Desktop/raylib/testRl /home/dimchee/Desktop/raylib/testRl/.zig-cache /home/dimchee/.cache/zig --seed 0x63c8ae38 -Z32e0671bb205eeae

My zig2nix setup:

# flake.nix
{
  inputs.zig2nix.url = "github:Cloudef/zig2nix";
  outputs = { zig2nix, ... }:
    let
      system = "x86_64-linux";
      env = zig2nix.outputs.zig-env.${system} {
        enableOpenGL = true;
        enableX11 = true;
      };
    in
    {
      devShells.${system}.default = env.mkShell { };
    };
}
// build.zig
const std = @import("std");

pub fn build(b: *std.Build) void {
    const target = b.standardTargetOptions(.{});
    const optimize = b.standardOptimizeOption(.{});
    const exe = b.addExecutable(.{
        .name = "test",
        .root_source_file = b.path("src/main.zig"),
        .target = target,
        .optimize = optimize,
    });
    b.installArtifact(exe);
    b.step("run", "Run the app").dependOn(&b.addRunArtifact(exe).step);
    const raylib_dep = b.dependency("raylib-zig", .{
        .target = target,
        .optimize = optimize,
        .linux_display_backend = .X11,
    });
    exe.linkLibrary(raylib_dep.artifact("raylib"));
    exe.root_module.addImport("raylib", raylib_dep.module("raylib"));
}
// build.zig.zon
.{
    .name = "name",
    .version = "0.0.0",
    .dependencies = .{
        .@"raylib-zig" = .{
            .url = "https://github.com/Not-Nik/raylib-zig/archive/devel.tar.gz",
            .hash = "1220ff1a9e774784fe3f11ffe71bc0186f9e62eb0fe1727f676d038b62665a5c74c5",
        },
    },
    .paths = .{
        "build.zig",
        "build.zig.zon",
        "src",
    },
}
@Cloudef
Copy link
Owner

Cloudef commented Sep 26, 2024

Hello, the problem is with raylib raysan5/raylib#4123

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

2 participants